Hi,
I am unable to validate date for I need to shutdown VM which are created for temp use.
Please help.
Script
$res = Import-Csv -Path .\date.csv -UseCulture |
ForEach-Object -Process {
$date = $res.MyDate
$startdate = '{0:yyyy-MM-dd}' -f $date
$today = (Get-Date -Format yyyy-MM-dd)
if($today -ge $startdate){
Write-Output "Run script"
Stop-VM -VM $res.Server -Kill -Confirm:$false
}else{
Write-Output "$res.Server still not expired"
}}
$res
Output
.csv contents
Server,Mydate
App01,12/25/2019
App02,12/25/2020
App03,04/24/2020