Follow sqlserver-dba.com

Subscribe to RSS feed  Follow @jackvamvas - Twitter

*Use the Comments section for questions

SQLServer-DBA.com Links

Dba_db2_button

dba-ninja.com

SQL Server DBA Jobs

How to get Cluster File Share Witness sharepath with Powershell

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


Author: Tom Collins (http://www.sqlserver-dba.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

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.

Working...

Post a comment on How to get Cluster File Share Witness sharepath with Powershell


sqlserver-dba.com | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer