Category: Microsoft Hyper-V

Microsoft Hyper-V – View All Virtual Machines in a Failover Cluster

You may use the following Microsoft Windows PowerShell cmdlet to view all of the virtual machines in a Microsoft Windows Hyper-V Failover Cluster. In order for this cmdlet to provide the list of virtual machines it will need to be run from a Hyper-V host in the cluster.

Get-ClusterGroup | ? {$_.GroupType -eq ‘VirtualMachine’ } | Get-VM


Microsoft Windows Powershell – Hyper-V Cmdlets

In order to view all of the Microsoft Hyper-V Cmdlets use the command get-command -module hyper-v. You may explore these commands and create scripts to automate your Hyper-V administration. Automation can save your Information Technology (IT) department both time and money.

01


Microsoft Hyper-V – Create a Virtual Switch using a PowerShell Script

Microsoft Hyper-V allows you to create (3) types of virtual switches (External, Internal and Private). These virtual switches may be created manually using the Hyper-V Manager or you may use a PowerShell (.ps1) script to automate the process. Below you will find a script to create an External virtual switch.

1. Issue the Get-NetAdapter command to provide a list of physical network interface (NIC) card(s) on the host. Take note of the name of the NIC that will be used for the external virtual switch.
01

2. You may modify the script below to create an external virtual switch.

02

3. Run Microsoft Powershell (as an Administrator) to create the external virtual switch.

03

4. Lastly, verify the creation of the virtual switch using the Hyper-V Manager > Virtual Switch Manager.

04


Microsoft Hyper-V – Install Hyper-V and the Management Tools using PowerShell

Microsoft allows you to install the Hyper-V role using PowerShell (run as an administrator) as well as the graphical user interface (GUI). One of the advantages of using PowerShell is that you can create a script to deploy a large number of Hyper-V hosts. During my initial testing I was able to install the Hyper-V role but the Management Tools were not being installed. The PowerShell installation requires the -IncludeManagementTools parameter to install the Management Tools.

The command to install both the Hyper-V role and the Management Tools is as follows:

Install-WindowsFeature –Name Hyper-V -ComputerName <computer_name> -IncludeManagementTools -Restart

01

If you will be installing the Hyper-V role on the local host then remove the -ComputerName <computer_name> parameter.

Microsoft provides great documentation for their solutions and the Install the Hyper-V Role and Configure a Virtual Machine document is no exception.

Enjoy!