Using PowerShell to Configure Virtual Machines on Multiple Computers at Once

Using PowerShell to Configure Virtual Machines on Multiple Computers at Once

Rate This
  • Comments 1


One of the handy things with Hyper-V PowerShell interfaces is that the majority of them can be used to target multiple computers at once.  Recently I needed to set all of my virtual machines to use a new VLAN.  I was able to do this with a single PowerShell command:

get-vm -computername benarm-alpha, benarm-beta, benarm-delta, benarm-gamma | Set-VMNetworkAdapterVlan -access -vlanid 99 –passthru

This command gets all the virtual machines from four computers (benarm-alpha, benarm-beta, benarm-delta and benarm-gamma) and sets the VLAN on all of them to 99.  Handy.

Cheers,
Ben

Leave a Comment
  • Please add 6 and 4 and type the answer here:
  • Post
  • Also, parallel VM moves

    workflow move-vms

    {

    $VMs = get-VM -Name "*"    

    foreach -parallel ($VM in $VMs)

    {

    sequence

    {

    $ab=$VM.Name

    Move-VM -Name $ab -IncludeStorage -DestinationHost "hyper-vhost3" -Verbose

    }

    }}

Page 1 of 1 (1 items)