A very simple yet useful way of dumping messages to a log file during the running of your powershell scripts is by using the following code snippet:-
$date = get-date -uformat %d/%m/%y" "%H:%M:%S
$date + " Creating OU: " + $ouname>>C:\Install\Logs\ModularADInstall.log
This code will basically log a message to file that begins with the date and time and then "Creating OU: followed by the vaule of the variable $ouname, the line in the log file could look something like this:-
18/08/08 13:15:40 Creating OU: OU1
If you want to change the date format then you can change this on the first line.
Showing posts with label Logging. Show all posts
Showing posts with label Logging. Show all posts
Monday, August 18, 2008
Subscribe to:
Posts (Atom)
