sdangi
sdangi

Reputation: 21

How to extract UNC path of all shares available in a server?

Please someone help me to create a batch file though which I can extract the UNC path of all shares available in one server. Its very tedious to manually find out from server manager as I have to open properties of every share folder and take the UNC path from it. Is there any specific powershell command or a batch script which I can run to extract for all available share folders. Thanks in advance for your help.

Upvotes: 1

Views: 3319

Answers (2)

FlorH
FlorH

Reputation: 1

You can use WMI specifically WIN32_Share to get Share Name, Path, and Description, then pipe the reply into a loop. Format the output to provide the UNC path, or send the output to a file

$SrvName = "YourServer"

gwmi -class win32_share -computer $SrvName | ForEach-Object {("\\"+$SrvName + "\" + $_.Name)}

Upvotes: 0

MC ND
MC ND

Reputation: 70933

Get it from wmi

wmic /node:yourServer share get name,path /format:csv

Upvotes: 2

Related Questions