PowerShell oneliner to change virtual switch settings on virtual machines

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.

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

Leave a Reply

Your email address will not be published. Required fields are marked *