PowerCLI: Refresh Host Networks

PowerCLI: Refresh Host Networks

I have been making automation scripts now for around 3 months and when provisioning VM’s I have found unless you refresh the host’s networking it will not appear. The following snippet resolves this issue for you but be aware that this can considerably slow down your script end to end execution time

Get-View -ViewType HostSystem -Property Name,ConfigManager | %{
(Get-View $_.ConfigManager.NetworkSystem).RefreshNetworkSystem()
Start-Sleep -Seconds 120
}

 

Advertisements