How to know if there are any shared folders in a directory?

Bernhard Lutz
Bernhard Lutz used Ask the Experts™
on
How to know if there are any shared folders in a directory?

Example:

Rootfolder
->Subfolder 1
Subfolder 1.1
which is shared
->Subfolder 2
Subfolder 2.1
which is also shared

I want a list which shows me the subfolder 1.1 and subfolder 2.1 and every share in other subfolders if they exist.

Thank you in advance!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2018
Distinguished Expert 2018

Commented:
Open a PowerShell console, enter
Get-WmiObject -Class Win32_Share | Select Name, Path, Description | Export-Csv -NoTypeInformation -Path "C:\Temp\shares.csv"

Open in new window

Bernhard LutzSystemadministrator / IT Security Administrator

Author

Commented:
With this command, I get every share on the system, but I want to filter it that it only displays the shares which are stored in a specific directory.
Most Valuable Expert 2018
Distinguished Expert 2018
Commented:
Filter ahead, either in Excel or when getting them:
Get-WmiObject -Class Win32_Share | Select Name, Path, Description | Where-Object {$_.Path -like "C:\RootFolder\*"} | Export-Csv -NoTypeInformation -Path "C:\Temp\shares.csv" 

Open in new window

Commented:
Have you tried using the MMC snap in for "Shared Folders"?  This should give you the shares for the system.  If it's a NAS system you should be able to add the computer object of the CIFS server and get the same information.

Commented:
If the directory or its parent(s) is listed, its shared.  I guess it could be possible a child to a shared parent could be excluded, I have never seen that.  

So,  if directory c:/a/b is shared then usually so is c:/a/b/c. and. c:/a/b/c/d etc.

So, just use explorer to look at c:/a/b and everything in there including the folders is shared.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial