Output the date/time in PowerShell -


i want output date time in various places in script logging doing this:

$b = get-date write-output "backups complete @ $b"  # more code here  $c = get-date write-output "backups complete @ $c" 

i having use multiple letters of alphabet current date/time.

is there easier way of doing or have reestablish date each time want use again?

once assign current datetime variable, capturing date , time @ moment ran get-date.

every time want new date , time, need run again. avoid using variable:

write-output "backups complete @ $(get-date)" 

Comments