RvdNieuwendijk
Leadership
Leadership

Script to update all your hosts

I made the following script to update all our hosts. It saves me a lot of time when updating all my hosts because now I can start the script and have just to wait untill all my hosts are updated. Before I had to put a host in maintenance mode, remediate the host and exit maintenance mode. And I had to do this for all my hosts. The script asumes that you use DRS in your clusters to move the VM's when you put a host in maintenance mode:

$Baseline = Get-Baseline -TargetType host
Get-VMhost | ForEach-Object {
  Set-VMhost  -vmhost $_ -state maintenance
  Remediate-Inventory -Entity $_ -Baseline $Baseline -Confirm:$False
  Set-VMhost -vmhost $_ -state connected
}

Have fun!

Robert van den Nieuwendijk

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
Tags (2)
Reply
0 Kudos