# encoding: ascii
# api: powershell
# title: Time-Stamp
# description: This is a very simple function that returns a DateTime time stamp. I use it in scripts for noting times when actions occur like this Write-Host “$(Time-Stamp): Attempting to create directory.”; It’s a lot shorter than writing out the whole thing. You can also alias it to simplify the process: New-Alias -Name ts -Value Time-Stamp;. This way I use Write-Host “$(ts): Attempting to create directory.”; It outputs: 2011.07.17 05:01:10: Attempting to create directory. You can alter the value in the ToString to change the way the time stamp is formatted.
# version: 0.1
# type: function
# author: Will Steele
# license: CC0
# function: Time-Stamp
# x-poshcode-id: 2795
# x-archived: 2016-10-30T02:09:02
# x-published: 2011-07-17T15:03:00
#
#
function Time-Stamp
{
return [System.DateTime]::Now.ToString("yyyy.MM.dd hh:mm:ss");
}
New-Alias -Name ts -Value Time-Stamp;