PowerShell Get List Of Folders Shared

powershellpowershell-3.0shared-folders

I am trying to get a list of folders that are shared on a file share. At the moment I have two test folders:

\\MYPC\Test1

\\MYPC\Test2

This is the code I have at the moment:

$FileServer = Read-Host "Enter file server to search"
$FolderList = Get-ChildItem -Path $FileServer

Write-Host $FolderList

But this comes up with "cannot find the path". I can see examples of how to do this for \\Server\Share as the directory, but is it possible to just search the \\Server?

Best Answer

Try this:

get-WmiObject -class Win32_Share -computer dc1.krypted.com

Ref: List Shares in Windows w/ PowerShell

Related Question