Quantcast
Channel: Microsoft – JeffOps
Viewing all articles
Browse latest Browse all 120

PowerShell oneliner to change virtual switch settings on virtual machines

$
0
0

Recently I’ve been asked howto use PowerShell to modify the virtual switch setting on VMs.
Specifically they wanted to migrate 30+ IIS virtual machines from one virtual switch to another.
This was because since their configuration was that each VLAN has their own virtual switch on the Hyper-V hosts.

Get-VM -Name "*IIS*" | ForEach-Object {Connect-VMNetworkAdapter -VMName $_.Name -SwitchName "vSwitch VLAN901"}

Why don’t I just use the pipe directly and avoid the ForEach all together?
The VMName parameter doesn’t take pipeline input ;-)

Post to Twitter


Viewing all articles
Browse latest Browse all 120

Trending Articles