What's Popular

Meh, Whatever is Featured

Linking Active Directory to Palo Alto

 ###First you need to create a server profile under the LDAP section. DEVICE>Server Profiles>LDAP then click on the Add down at the bo...

Friday, October 12, 2018

PowerCLI Mass VM Port Group Change

1.    First off, you will have to declare your variables once you are logged into the vCenter server. You do this by the following:
    a.    You can declare your cluster variable with: $Cluster = “TestCluster”
    b.    You can then you can declare your old network with: $OldNetwork = “TestPG”
    c.    Finally, set the variable for the new network with: $NewNetwork = “NewTestPG”

2.    Now your variables are set and you can now pull them in the following script:
    a.    Get-Cluster $Cluster |Get-VM |Get-NetworkAdapter |Where {$_.NetworkName –eq $OldNetwork} |Set-NetworkAdapter –NetworkName $NewNetwork –Confirm:$false

3.    That is for clusters, if you just want to do all your VMs, you can do the following:
    a.    Declare your variables:
        i.    Set your variable for the old PortGroup: $OldNetwork = “TestPG”
        ii.    Set the variable for the new PortGroup: $NewNetwork = “NewTestPG”

4.    Now you set your variables for your port groups, you can go ahead and execute your script with the declared variables:
    a.    Get-VM |Get-NetworkAdapter |Where {$_.NetworkName –eq $OldNetwork} |Set-NetworkAdapter –NetworkName $NewNEtwork –Confirm:$false

5.    You should see the process go through in the PowerCLI area and also you should see it in vCenter.

No comments:

Post a Comment