09 May,2022 by Tom Collins
Question: I normally use the Windows reg utility to get the Cluster File Share Witness sharepath information. This is an example command line on a server returning the File Share Witness details
reg query \\myCluster\HKEY_LOCAL_MACHINE\Cluster\Resources /s /f sharepath
I want to start integrating these sorts of tasks into automated information gathering procedures and migrate this task into the Powershell library. Could you share some Powershell code to get the Cluster File Share Witness sharepath information
Answer: This powershell code is a starting point for getting the Cluster Fileshare witness sharepath details.
Get-clusterresource -cluster MyCluster | where-object {$_.ResourceType -like "File Share Witness"} | get-clusterparameter -Name "sharepath" | Select Value
The command is made up of a number of different commands:
Get-Clusterresource gets information about resources in the failover cluster
Get-Clusterparameter Gets information details about a failover cluster object, in the example above the File Share Witness sharepath . If you execute just the first part of the statement - Get-clusterresource -cluster MyCluster , you will get a full list of the Cluster resources and Resource Type - usch as IP Address, Network Name , File Share Witness , SQL Server Availability Group
Read more on managing SQL Server related Clustering
Quick access to Failover Clustering cheatsheet
How to get the Always On Availability Group DNS name per database
This is only a preview. Your comment has not yet been posted.
As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.
Having trouble reading this image? View an alternate.
Posted by: |