I have a path in a string,
C:\temp\mybackup.zip
I would like insert a timestamp in that script, for example,
C:\temp\mybackup 2009-12-23.zip
Is there an easy way to do this in PowerShell?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can insert arbitrary PowerShell script code in a double-quoted string by using a subexpression, for example, $() like so:
And if you are getting the path from somewhere else – already as a string:
And if the path happens to be coming from the output of Get-ChildItem: