Hi,
I am trying to get a yesterday's date into a variable:
$timestamp = (Get-Date).AddDays(-1) -Format yyyy-MM-dd
This errors, so I have to use AddDays method without the Format option:
$timestamp = (Get-Date).AddDays(-1)
$DBScriptFile = "\\MyServer\Scripts\MyDb\08_SPs " + $timestamp.Year + '-' + $timestamp.Month +'-' + $timestamp.Day + ".sql"
But I get:
\\MyServer\Scripts\MyDb\08_SPs 2011-11-1.sql
But I need to get:
\\MyServer\Scripts\MyDb\08_SPs 2011-11-01.sql
I want to get the desired format without going into too much complexity in script logic.
Any ideas?