VMware Cloud Community
heskez
Contributor
Contributor
Jump to solution

New vm migrate DVS/PG script

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

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

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

0 Kudos
heskez
Contributor
Contributor
Jump to solution

You nailed it, thanks!

Erik

0 Kudos