Recently in the PowerShell to do some of the regular daily work, want to get the results in real time, like Linux installation software, a piece of the real-time output to the console, so it is clear to see the results of each step of execution. The format is like this:
PS > 02/28/2018 13:35:43 Checking xxx service ....
02/28/2018 13:35:44 XXX service is stopped.
02/28/2018 13:35:45 starting XXX service ....
02/28/2018 13:35:46 XXX Service is started.
I am also a PowerShell beginner, at first in order to achieve this time in real time display, with a very stupid method, is each output statement before the definition of a time variable, this is too cumbersome, there must be a simple way to achieve. In the group asked a master, sure enough. PowerShell defines a variable in a way that is straightforward: $ (powershell-command).
For example: $ (get-date)
You can use it directly. The following is a complete example:
PowerShell-Output execution results like log