I've been struggling for days to use this parameter.
In the help it is said that it is a DateTime parameter, but when giving a datetime, I recieve an error saying that only datetimes are accepted :(
for instance :
$dte = Get-Date
$dte = $dte.AddDays(7).
Backup-SqlDatabase [...] -ExpirationDate $dte fails.
Then I tried with a string representing a date, like "2013-09-01".
No error anymore ! But it seems that the month (09) and day (01) are inverted when I look in the support in SQL Server.
When trying with "2013-13-09", I get an error saying that it can't be converted into a valid date/time. So I think Powershell can't obviously convert it, and I can anderstand it.
When trying with "2013-09-13", I get an error saying that it's not a valid value for parameter EXPIREDATE.
As a conslusion, I think there is a bug in the snippet :
- It tries to convert first the string as a date/time in powershell (I think it is OK)
- Then it should be converted inside an SQL Server Date/Time, but there is an inversion between MONTH and DAY.