Q
Get started Bring yourself up to speed with our introductory content.

How do you find Hyper-V nodes with PowerShell?

Manage Hyper-V clusters more easily with PowerShell cmdlets and scripts that automate the retrieval and display of node information, including node statuses.

With a few PowerShell commands, you can efficiently find all the Hyper-V nodes available in a Hyper-V cluster,...

and with a PowerShell script, you can easily save that data as a readable file.

PowerShell is becoming the first choice for IT administrators to perform command-line operations. With PowerShell, you can automatically create a Hyper-V cluster and deploy a VM. Microsoft provides full PowerShell support for Windows failover clusters, including cmdlets you can use to manage a Hyper-V cluster. There are a bunch of cmdlets available to use with Hyper-V clusters, but the focus of this article is on finding Hyper-V cluster nodes.

You can use the Get-ClusterNode PowerShell cmdlet to find all Hyper-V nodes in a Hyper-V cluster. Below are some examples that use the Get-ClusterNode cmdlet.

Type Get-ClusterNode to list all the Hyper-V nodes available in a Hyper-V cluster.

Hyper-V nodes.
Figure A. Use the Get-ClusterNode cmdlet to list all Hyper-V nodes.

The command to the left targets the current Hyper-V cluster and shows the list of available Hyper-V nodes with an Up status. If you want to get available Hyper-V nodes from a specific cluster, use the -Cluster parameter, as shown below.

Get-ClusterNode –Cluster HyperVPRODCluster

If you have more than one Hyper-V cluster, you can create a text file that contains the Hyper-V cluster names and then execute a PowerShell script that collects the results and saves them in a C:\Temp\ClustNodes.CSV file.

PowerShell script.
Figure B. Execute a PowerShell script to create a text file with cluster information.

The script to the left gets each cluster name from the C:\Temp\ClusterNames.TXT file, executes the Get-ClusterNode command against each cluster and then saves the output in a C:\Temp\ClustNodes.CSV file.

Cluster names.
Figure C. Use a PowerShell script to display the cluster each node is from.

Apart from including the node name hosted in a cluster, the result also shows the statuses of the Hyper-V nodes, as indicated in the third column of Figure C to the left.

This was last published in November 2018

Dig Deeper on Microsoft Hyper-V and Virtual Server

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Join the conversation

1 comment

Send me notifications when other members comment.

Please create a username to comment.

What techniques do you use to manage Hyper-V clusters?
Cancel

-ADS BY GOOGLE

SearchVMware

SearchWindowsServer

SearchCloudComputing

SearchVirtualDesktop

SearchDataCenter

Close