Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 168400

Re: Delete VM on the specified date

$
0
0

Interesting, I tried a small change, and I moved [datetime] in front of the $dt, and it seems to be working.  Thanks for your help, but I'm curious why it works this way. 

 

$now = Get-Date

 

Get-folder Test | Get-VM | where {$_.name -cmatch "Delete-\d\-\d\-\d"} | foreach {

 

[datetime]$dt=($_.name.Split("-",2)[1])

if ($dt.Month -eq $now.Month) {

 

Remove-VM -VM $_ -Confirm

}

 

 

}


Viewing all articles
Browse latest Browse all 168400

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>