VMware Cloud Community
tdubb123
Expert
Expert

runasync

how can i run this as one job and not one host at a time? I dont see a runasync option

$vmhosts = get-vmhost -name (get-content esxhosts.txt)

foreach ($vmhost in $vmhosts) {

get-vmhost $vmhost | get-advancesetting -name "Uservars.ESXiShelltimeout" | set-advancedsetting -value "0" -confirm:$false

get-vmhostservice -vmhost $vmhost | ? {$_.key -eq "TSM-SSH"} | restart-vmhostservice -confirm:$false

}

Reply
0 Kudos
1 Reply
LucD
Leadership
Leadership

That is correct, there is no RunAsync switch on these cmdlets.

You could opt to use the underlying API methods for this.
The drawback is that doing it this way is quite a bit more complex compared to using the cmdlets.
And some of the underlying API methods do not have a background task option either.

An alternative is to use Start-Job to launch a number of these in the background.

But that would only really make sense when you are talking about rather big numbers of ESXi nodes.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos