How to get the list of shared folders using PowerShell?


Get-SmbShare gives all the shared folders on the local system.

PS C:\Temp> Get-SmbShare
Name    ScopeName    Path       Description
----    ---------    ----       -----------
ADMIN$    *       C:\Windows    Remote Admin
C$        *       C:\ Default    share
DSC       *       E:\DSC
E$        *       E:\           Default share
IPC$      *                      Remote IPC
Shared1   *       E:\Extract

Example

To get the shared folders on the remote computer we can use the CIM session. For example,

$sess = New-CimSession -ComputerName Labmachine2k16
Get-SmbShare -Session $sess

Output

PS C:\Users\Administrator> Get-SmbShare -Session $sess
Name       ScopeName Path          Description    PSComputerName
----       --------- ----          -----------    --------------
ADMIN$       *       C:\Windows    Remote Admin    Labmachine2k16
C$           *       C:\ Default   share           Labmachine2k16
DSC          *       E:\DSC                        Labmachine2k16
E$           *       E:\           Default share   Labmachine2k16
IPC$         *                     Remote IPC      Labmachine2k16
Shared1      *       E:\Extract                    Labmachine2k16

Updated on: 01-Mar-2021

6K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements