Book Image

Microsoft Hyper-V PowerShell Automation

By : Vinith Menon
Book Image

Microsoft Hyper-V PowerShell Automation

By: Vinith Menon

Overview of this book

Table of Contents (13 chapters)
Microsoft Hyper-V PowerShell Automation
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Extracting information about Hyper-V hosts and the associated virtual machines


Microsoft offers the ability to extract information related to the Hyper-V infrastructure using PowerShell. It is now possible to perform virtual machine management from the command line using the Hyper-V PowerShell module.

Let's start exploring the ways in which you can extract information related to a Hyper-V host.

For Hyper-V deployments that are not clustered, host-level information can be extracted by the Get-VMHost cmdlet:

Get-VMHost | fl *

Open up a PowerShell prompt in your Windows Server 2012 R2 Hyper-V server in the Run as Administrator mode and type the following cmdlets:

  • Get-ClusterNode: This cmdlet shows details of the nodes in the cluster

  • Get-ClusterNode | select @{l='ComputerName';e={$_.name}}: This cmdlet shows the names of the Hyper-V hosts in the cluster

  • Get-VMHost –computername <HVHostName>: This cmdlet shows details of the Hyper-V hosts

Now, by combining all the preceding cmdlets together...