Hi Folks, not sure if this is right location.
Currently we are doing bulk power operations of VMs like below. Is there anyway, if we execute this, first it will just pop up/list all VMs from the file to confirm operation before executing it than one by one? I just don't want to skip confirmation with Confirm:$false; neither do it one at a time.
Shutdown-VMGuest -VM (Get-Content <textfile>
Thanks for any help!
Cheers,
Hari
Moderator: Moved to PowerCLI Discussions
You mean something like this?
$vmNames = Get-Content -Path <textfile>
$vms = Get-VM -Name $vmNames
Format-Wide -InputObject $vms -Property Name -Column 4
$answer = Read-Host -Prompt "Is it ok to shutdown these VMs? (y/n)"
if($answer -eq 'y'){
Shutdown-VMGuest -VM $vms -Confirm:$false
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD, hope you doing good!
Yeah, I believe it should do, will test it today.
Cheers,
Hari