I have the following script I am trying to use to copy my Standard vSwitch port groups to vDS
$InputHost = Read-Host "Host Name"
$InputvSwitch = Read-Host "vSwitch Name"
$InputDvS = Read-Host "Distributed vSwitch Name"
$vmhost = Get-VMHost $InputHost
$vss = Get-VirtualSwitch -Name $InputvSwitch
$vssNumPorts = $vss.NumPorts
$standardpg = $vmhost | $vss | Get-VirtualPortGroup
$dvs = Get-VDSwitch $InputDvS
foreach ($i in $standardpg) {
$pvgname = $i.name.ToString()
$pvg = "dv-" + $pvgname
$vlan = $i.VLANID
When I run it I get an error "Expressions are only allowed as the first element of a pipeline." for the $standardpg = $vmhost | $vss | Get-VirtualPortGroup command
Anyone have any idea why.