tryijg to automate the patching of esx hosts
reading them from a txt file, putting one at a time in maintenance mode, scan, patchin, reboot, then next host
will this work?
import-module Vmware.VimAutomation.Core
import-module Vmware.Vumautomation
$vmhosts = get-vmhost -name (get-content "c:\scripts\vmhosts.txt") {
foreach ($vmhost in $vmhosts) {
get-vmhost -Name $vmhost | Set-VMHost -State Maintenance -Confirm:$false
Get-Baseline -Name *Critical* | Attach-Baseline -entity $vmhost -Confirm:$false
Scan-Inventory -Entity $vmhost
get-baseline -name *Critical* | Remediate-Inventory -Entity $vmhost -Confirm:$false -erroraction Silentlycontinue
get-vmhost -name $vmhost | set-vmhost -state Connected -Confirm:$false
}
anything I can tweak or should be aware of?
Thanks