Posted in
Windows Powershell |
No Comment | 5,127 views | 07/06/2009 10:21
This is a basic script to create timestamp using Get-Date command.
1
2
3
4
5
6
7
8
9
10
11
| Function TimeStamp
{
$now=Get-Date
$yr=$now.Year.ToString()
$mo=$now.Month.ToString()
$dy=$now.Day.ToString()
$hr=$now.Hour.ToString()
$mi=$now.Minute.ToString()
write-output $yr$mo$dy$hr$mi
}
$timestamp = TimeStamp |
Function TimeStamp
{
$now=Get-Date
$yr=$now.Year.ToString()
$mo=$now.Month.ToString()
$dy=$now.Day.ToString()
$hr=$now.Hour.ToString()
$mi=$now.Minute.ToString()
write-output $yr$mo$dy$hr$mi
}
$timestamp = TimeStamp
You can use timestamp with any script to create random files.