While working with PowerShell scripts, quite frequently you may find a need to create a file to store information. The following lines can help you in creating a file name with TimeStamp.
"MyLogFile-$(get-date -uformat '%Y-%m-%d-%H-%M-%S-%p').log"
The output is something like...
MyLogFile-2013-03-13-14-07-40-PM.log
To create a new file at a specific $Path, use the following...
$LogFile = new-item -type file -name "MyLogFile-$(get-date -uformat '%Y-%m-%d-%H-%M-%S-%p').log" -path "$Path"
$LogFile fill contain the handle and you can easily do an Add-Item $LogFile "Something"
Hope this helps,
Rahul
Quote of the day:
"Most advances in science come when a person for one reason or another is forced to change fields." - Peter Borden