The five best Windows PowerShell v3 commands every admin should know

3/6

Running the Invoke-Command cmdlet for bulk operations

The Invoke-Command cmdlet performs bulk PowerShell operations against multiple targets. This allows you to more easily manage large numbers of VMs because you can run the cmdlet against multiple Hyper-V hosts. Simply include the –ComputerName switch with the names of the target servers separated by commas and the command that you want to run on the remote servers enclosed in braces.

Suppose for a moment that you want to retrieve the name, state and status of all VMs running on servers named Lab1 and Lab2. You could accomplish this task with the following PowerShell v3 command:

Invoke-Command –ComputerName Lab1, Lab2 {Get-VM | FT VMName, State, PrimaryStatusDescription}

The image shows an example of this command. As you can see, the Invoke-Command directs the Get-VM command at multiple Hyper-V hosts. It also retrieves specific attributes for each VM by specifying those that should be displayed.

View All Photo Stories

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchVMware

SearchWindowsServer

SearchCloudComputing

SearchVirtualDesktop

SearchDataCenter

Close