Saturday 28 September 2019

PowerShell Get List Of Folders Shared


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?



Answer



Try this:


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

Ref: List Shares in Windows w/ PowerShell


No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...