PoweShell TTUC (Tips, Tricks and Useful Commands) #16 – File Name with Time Stamp

File can be created with date / time suffix using the following syntax / commands:

New-item -type file -Name (“MyFile_$(Get-Date -f MM-dd-yyyy_hh-mm-ss).txt”) –force

New-item cmdlet will create a new file.  Get-data cmdlet will append date and time in MM-dd-yyyy_hh-mm-ss format. 

http://www.amazon.com/dp/1849687447/?tag=packtpubli-20

Powered by WPeMatico

Categories: Microsoft

Related Posts

Microsoft

Azure – Your account is temporarily locked to prevent unauthorized use

Here is the another common error message when dealing with directory and password synchronization.  Error Message: Your account is temporarily locked to prevent unauthorized use. Try again later. Contact Customer Support if the problem persists Read more…

Microsoft

Verify Service Status Remotely Using Local Account – PowerShell Script

I have modified one of my previously published script – Stop, Start, Disable Service Remotely–PowerShell Script (http://portal.sivarajan.com/2011/05/stop-start-disable-service.html) to use Local account (instead of a domain account) to verify the status of the service.   Input Read more…

Microsoft

Collect Computer Information From Active Directory– PowerShell Script

This PowerShell script can be used to collect computer information from Active Directory.   I am searching only Windows XP and Windows 7 machines.  You can update these values  by modifying $OS1 and $OS2 variables. $OS1 Read more…