Hello,
i'm new the PowerShell and looking for a way to rename multiple portgroups on a distributed virtual switch.
Is there a "simple" way to fix a simple typing mistake?
Portgroup name is "XYZ-pubic" but should be "XYZ-public". XYZ is variable.
Thank you,
Marcel
Did you check these already?
http://communities.vmware.com/message/1475219#1475219
http://communities.vmware.com/message/1173158#1173158
Hello,
thanks for the reply.
I know the command for changing the portgroup name.
But i hope that there is any posibility to replace the "pubic" to "public" (i think there must be a way with "foreachobject").
Try something like this
$dvSw = Get-VirtualSwitch -Name MydvSw
$spec = New-Object VMware.Vim.DVPortgroupConfigSpec
Get-View $dvSw.ExtensionData.Portgroup | %{ if($_.Name -like "*-pubic"){ $spec.Name = $_.Name -replace 'pubic','public'
$spec.configVersion = $_.Config.ConfigVersion $_.ReconfigureDVPortgroup($spec) } }
Or if you want to do this for all your dvSwitches, you could do
$spec = New-Object VMware.Vim.DVPortgroupConfigSpec Get-VirtualSwitch | %{ Get-View $_.ExtensionData.Portgroup | %{ if($_.Name -like "*-pubic"){ $spec.Name = $_.Name -replace 'pubic','public'
$spec.configVersion = $_.Config.ConfigVersion $_.ReconfigureDVPortgroup($spec) } } }
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
