Managing File Shares

by Jan 13, 2023

The Windows operating system ships with the “Storage” PowerShell module which can be used both from Windows PowerShell and PowerShell 7.

One of the many things this module manages is file shares albeit you may need Administrator privileges to run the following cmdlets.

To just get a list of file shares (local folders that are accessible over the network), try this:

PS C:\> Get-FileShare

Name   HealthStatus OperationalStatus
----   ------------ -----------------
ADMIN$ Healthy      Online
C$     Healthy      Online
print$ Healthy      Online

PS C:\> Get-FileShare -Name c$

Name HealthStatus OperationalStatus
---- ------------ -----------------
C$   Healthy      Online

PS C:\> Get-FileShare -Name c$ | Select-Object -Property *

HealthStatus          : Healthy
OperationalStatus     : Online
ShareState            : Online
FileSharingProtocol   : SMB
ObjectId              : {1}\\DELL7390\root/Microsoft/Windows/Storage/Providers_v2\WSP_FileShare.ObjectId="{c0c2f698-c81d-11e9-9f6f-80
PassThroughClass      : 
PassThroughIds        : 
PassThroughNamespace  : 
PassThroughServer     : 
UniqueId              : smb|DELL7390/C$
ContinuouslyAvailable : False
Description           : Standardfreigabe
EncryptData           : False
Name                  : C$
VolumeRelativePath    : \
PSComputerName        : 
CimClass              : ROOT/Microsoft/Windows/Storage:MSFT_FileShare
CimInstanceProperties : {ObjectId, PassThroughClass, PassThroughIds, PassThroughNamespace...}
CimSystemProperties   : Microsoft.Management.Infrastructure.CimSystemProperties   

Likewise, other verbs allow related tasks such as changing an existing share (Set) or creating a new share (New):

PS C:\> Get-Command -Noun FileShare

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Function        Debug-FileShare                              Storage
Function        Get-FileShare                                Storage
Function        New-FileShare                                Storage
Function        Remove-FileShare                             Storage
Function        Set-FileShare                                Storage

Tweet this Tip! Tweet this Tip!