Hi,
I´ve imported a backup from one distributed virtual switch to a new one with another name. However all the imported portgroups gets a (0) suffix. Since there are lots of portgroups I´d like remove the (0) suffix from the PGs on the dVswitch. Does anyone have a script for a similar operation?
Thanks,
And if you try like this?
$vdSwName = "vds1"
Get-VDSwitch -Name $vdSwName |
Get-VDPortgroup -PipelineVariable pg |
where{$_.Name -match "(0)$"} |
Foreach-Object -Process {
Set-VDPortgroup -VDPortgroup $pg -Name ($pg.Name.TrimEnd('(0)')) -Confirm:$false
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try something like this
$vdSwName = vds1"
Get-VDSwitch -Name $vdSwName |
Get-VDPortgroup |
where{$_.Name -match "(0)$"} |
Set-VDPortgroup -Name ($_.Name.TrimEnd('(0)')) -Confirm:$false
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi,
Thanks for your reply. However I get this error "You cannot call a method on a null-valued expression.".
The selections work but not the last set-vdportgroup part.
And if you try like this?
$vdSwName = "vds1"
Get-VDSwitch -Name $vdSwName |
Get-VDPortgroup -PipelineVariable pg |
where{$_.Name -match "(0)$"} |
Foreach-Object -Process {
Set-VDPortgroup -VDPortgroup $pg -Name ($pg.Name.TrimEnd('(0)')) -Confirm:$false
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That did the trick! Many thanks!