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.
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