Hi, there,
Can you provide the format of the csv file? An example would be good.
How do you like to filter them ? Which VMs are going to be removed and shut down ?
Other than deserialization of the csv file to .net objects, it's easy to write such as scirrpt:
$vms = <deserialize-from-custom-csv>
$filteredVMs = $vms | ?{ <condition>}
you have 2 approaches here:
$filteredVMs | Shutdown-VMGuest -confirm:$false
or
$filteredVMs | Stop-VMt -confirm:$false
Then I suppose you would want to serialize to CSV again
you can do the following:
$remainingVMs = @()
foreach( $vm in $vms){
if($filteredVms -notcontains $vm){
$remainingVMs += $vm
}
}
Export-CSV -Path <your-file-here> -InputObject
$remainingVMs
If you have trouble in finished the script, don't hesitate to ask.
Best regards,
Leni Kirilov
PowerCLI Team
Export-CSV