Hello,
The file server for the network shares of my company is a member of the MS cluster. There are three servers in the cluster.
I need to get the server name from the hiden shares from the the cluster resource. Since any of the three servers can be the active cluster node, I need to query the server name from the shares instead of pointing to a certain server as the file server name.
I have a way to determine the active node (server name) of the cluster resource for the shares, but I need to query the server name with WMI since I need to use an alternate credential when I query the server from the share.
I know that the Win32_ShareToDirectory class of the WMI can return the server name with either of the two properties: Share and SharedElement.
The script code below maps the network share to a local folder name.
Is there any way to modify the code so that I can get the server name from the share instead?
strShare = "MyShare"
strComputer = "CLUSTER_RESOURCE_NAME"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colShares = objWMIService.ExecQuery _
("Associators of {Win32_Share.Name='" & strShare & "'} Where " _
& "AssocClass=Win32_ShareToDirectory")
For Each objFolder in colShares
Wscript.Echo objFolder.Name
Next
The file server for the network shares of my company is a member of the MS cluster. There are three servers in the cluster.
I need to get the server name from the hiden shares from the the cluster resource. Since any of the three servers can be the active cluster node, I need to query the server name from the shares instead of pointing to a certain server as the file server name.
I have a way to determine the active node (server name) of the cluster resource for the shares, but I need to query the server name with WMI since I need to use an alternate credential when I query the server from the share.
I know that the Win32_ShareToDirectory class of the WMI can return the server name with either of the two properties: Share and SharedElement.
The script code below maps the network share to a local folder name.
Is there any way to modify the code so that I can get the server name from the share instead?
strShare = "MyShare"
strComputer = "CLUSTER_RESOURCE_NAME"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colShares = objWMIService.ExecQuery _
("Associators of {Win32_Share.Name='" & strShare & "'} Where " _
& "AssocClass=Win32_ShareToDirectory")
For Each objFolder in colShares
Wscript.Echo objFolder.Name
Next