In this article, you will learn on how to create a folder share using a PowerShell command. First, you need to determinate which folder you want to share, or you can create a new folder using New-Item cmdlet as below

New-Item "C:\SharedFolder" -Type Directory

You can also add the -Force parameter to make the folder with multiple level (e.g “C:\NewRootFolder\NewChildFolder\SharedFolder”)

Share the Folder

After you create the folder, now you can run New-SMBShare cmdlet to share the folder. The New-SmbShare cmdlet exposes a file system folder to remote clients as a Server Message Block (SMB) share.

 New-SmbShare -Name "FolderShare" -Path "C:\SharedFolder" -FullAccess "MSNOOB\Administrators", "MSNOOB\MS-RDS1$" 

Command Parameter

Here are the parameters that you may need to get just the right experience for your network shares.

Parameter NameInput TypeRequiredDescription
CATimeoutIntegerNoHow many seconds to wait before failing.
CachingModeChoice:
None, Manual, Documents, Programs, BranchCache, Unknown
NoThe caching policy for the share.
ChangeAccessString or String ArrayNoUsers to grant Read/Write access to.
Concurrent User LimitIntegerNoHow many users can access the share at a time.
ContinuouslyAvailableBoolean (switch)NoWhether to keep the share after the next reboot.
DescriptionStringNoFriendly description of the share.
EncryptDataBoolean (switch)NoUse to turn on file encryption.
FolderEnumerationModeChoice:
AccessBased, Unrestricted
NoChoose when folders are enumerated (listed) in the share.
FullAccessString or String ArrayNoUsers to grant Full control to.
NameStringYesName of the share.
NoAccessString or String ArrayNoUsers to deny access to.
PathStringYesThe file path to the shared folder.
ReadAccessString or String ArrayNoUsers to grant Read Only access to.
ScopeNameStringNoName of the endpoint that the share is scoped to.
TemporaryBoolean (switch)NoShare removed after reboot.
ThrottleLimitIntegerNoLimit the resources of the share.
AsJobBoolean (switch)NoCreate a Job to background process this command