Typed before I truly tested. Although, the script works, I am still getting this error:
Cannot convert value "Delete-09-09-13" to type "System.DateTime". Error: "The string was not recognized as a valid DateTime. There is an unknown word starting at index 0."
Overall, this is the main part of the script, and again, thanks for your help
$now = Get-Date
Get-folder Test | Get-VM | where {$_.name -cmatch "Delete-\d\d\-\d\d\-\d\d"} | foreach {
[datetime]$dt=($_.name.Split("-",2)[1])
if ($dt.Month -eq $now.Month -and $dt.Day -eq $now.Day -and $dt.Year -eq $now.Year) {
Remove-VM -VM $_ -Confirm
}
}
I receive the notification to remove the VM, but I also receive the error message. I guess I could just silientlycontinue, but I'm curious why this happens. I've tried the script on 2 VMs, and it always works, I just don't know why the message comes up. In any event, thanks for leading me on the right path.