Find network drives and UNC path

(imported topic written by NHolmes91)

Is there a way that i can find all the network drives that the clients map to and return the UNC path for each?

(imported comment written by brolly3391)

I started with the available inspector:

q: names of drives

A: A:

A: C:

A: D:

A: G:

A: H:

A: L:

T: 0.211 ms

It’s screaming fast but does not seem to be any property of the Drive object that exposes FullUNCPath. So I gave up on that and went to WMI with:

q: (selects (“ProviderName from win32_LogicalDisk”)of WMI)

A: ProviderName

A: ProviderName

A: ProviderName

A: ProviderName=\SERVER1\SHARE1

A: ProviderName=\SERVER2\SHARE2$

A: ProviderName=\SERVER3\SHARE3$

T: 52.167 ms

Which was really close to what you were looking for and not too terribly slow for a WMI call. Then I cleaned up the results with

q: substrings after 
"=" of (selects (
"ProviderName from win32_LogicalDisk")of WMI as string) A: \\SERVER1\SHARE1 A: \\SERVER2\SHARE2$ A: \\SERVER3\SHARE3$ T: 53.597 ms

that should be what you were looking for.

I also tried to get fancy with correlating the drive letter with the sharename but it was too darn slow.

q: (if property “ProviderName” of it as string contains “=” then (substring after “=” of (property “Name” of it as string) &" – " & substring after “=” of (property “ProviderName” of it as string)) else nothing) of select objects("* from win32_LogicalDisk")of WMI

A: G: – \SERVER1\SHARE1

A: H: – \SERVER2\SHARE2$

A: L: – \SERVER3\SHARE3$

T: 1435.511 ms

(imported comment written by NHolmes91)

Thanks, It working great. I’m having to use drive letter with the share name. But i am only needing to pull it once a day so its not that bad.

(imported comment written by brolly3391)

ok, I did not expect that you wanted the correlation.

I made a slight change to the fancy version. Instead of pulling * I am just pulling the 2 fields that we need. Improved the speed a lot.

q: (if property “ProviderName” of it as string contains “=” then (substring after “=” of (property “Name” of it as string) &" – " & substring after “=” of (property “ProviderName” of it as string)) else nothing) of select objects(“Name,ProviderName from win32_LogicalDisk”)of WMI

A: G: – \SERVER1\SHARE1

A: H: – \SERVER2\SHARE2$

A: L: – \SERVER3\SHARE3$

T: 62.669 ms

(imported comment written by rmustapha91)

WHAT CAN I DO IF i WANT TO CHECK FOR THE EXISTENCE OF ONLY ONE OF THE NETWORK DRIVE. FOR EXAMPLE IN THE RESULT BELOW, I WILL LIKE TO CHECK IF THIS PART “\deguggin\post-” IS MAPPED TO “M” ONLY.

q: (if property “ProviderName” of it as string contains “=” then (substring after “=” of (property “Name” of it as string) &" IS MAPPED TO " & substring after “=” of (property “ProviderName” of it as string)) else nothing) of select objects(“Name,ProviderName from win32_LogicalDisk”)of WMI

A: M: IS MAPPED TO \debugging\post-

A: Y: IS MAPPED TO \westool\webtools

(imported comment written by jessewk)

Here you go:

exists select objects (“Name,ProviderName from win32_LogicalDisk”) whose (string value of property “ProviderName” of it as lowercase = “\ce-debug-serv\post-silicon” AND string value of property “Name” of it as lowercase = “m:”) of WMI

(imported comment written by rmustapha91)

Thank you so much. It worked

(imported comment written by rmustapha91)

I tried the above relevance in bigfix deployment console on a system that should passed but failed.but it failed. but if I run it on the system itself, it passed.Do you know a work around on this?

(imported comment written by jessewk)

The problem is likely related to the current user context. The mapped drives probably don’t exist for the system user. Unfortunately I don’t know how to get the correct information out of wmi.

(imported comment written by rmustapha91)

Thanks

(imported comment written by JamesN91)

rmustapha

I tried the above relevance in bigfix deployment console on a system that should passed but failed.but it failed. but if I run it on the system itself, it passed.Do you know a work around on this?

Is there a fix to this as of yet?

I am having the same issue.

(imported comment written by rmustapha91)

Not that I know of. In other to make the relevance passed for a network drive, the account that mapped the drive needs to be logged into the system.

(imported comment written by JackCoates91)

use a recurring task with runascurrent user to capture the information to a text file or HKLM registry key, then read from that location.