I'd like to expand this script with the possiblilty to type any vm useable for migration.
I get this error
Strings as pipeline input are not supported
$strvm = Read-Host "Please enter the vm name" | Get-NetworkAdapter | Set-NetworkAdapter -NetworkName (Get-VirtualSwitch -Distributed -Name MyDVSwitch| Get-VirtualPortGroup -Name "virtual machines").Name
Try like this
$strvm = Read-Host "Please enter the vm name"
Get-VM -Name $strvm | Get-NetworkAdapter | Set-NetworkAdapter -NetworkName (Get-VirtualSwitch -Distributed -Name MyDVSwitch| Get-VirtualPortGroup -Name "virtual machines").Name
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try like this
$strvm = Read-Host "Please enter the vm name"
Get-VM -Name $strvm | Get-NetworkAdapter | Set-NetworkAdapter -NetworkName (Get-VirtualSwitch -Distributed -Name MyDVSwitch| Get-VirtualPortGroup -Name "virtual machines").Name
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You nailed it, thanks!
Erik