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
                        6e6f6e6963}:FX:SMB||*||C$"
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                                    2.0.0.0    Storage
Function        Get-FileShare                                      2.0.0.0    Storage
Function        New-FileShare                                      2.0.0.0    Storage
Function        Remove-FileShare                                   2.0.0.0    Storage
Function        Set-FileShare                                      2.0.0.0    Storage
 


Tweet this Tip! Tweet this Tip!