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 Name | Input Type | Required | Description |
CATimeout | Integer | No | How many seconds to wait before failing. |
CachingMode | Choice: None, Manual, Documents, Programs, BranchCache, Unknown | No | The caching policy for the share. |
ChangeAccess | String or String Array | No | Users to grant Read/Write access to. |
Concurrent User Limit | Integer | No | How many users can access the share at a time. |
ContinuouslyAvailable | Boolean (switch) | No | Whether to keep the share after the next reboot. |
Description | String | No | Friendly description of the share. |
EncryptData | Boolean (switch) | No | Use to turn on file encryption. |
FolderEnumerationMode | Choice: AccessBased, Unrestricted | No | Choose when folders are enumerated (listed) in the share. |
FullAccess | String or String Array | No | Users to grant Full control to. |
Name | String | Yes | Name of the share. |
NoAccess | String or String Array | No | Users to deny access to. |
Path | String | Yes | The file path to the shared folder. |
ReadAccess | String or String Array | No | Users to grant Read Only access to. |
ScopeName | String | No | Name of the endpoint that the share is scoped to. |
Temporary | Boolean (switch) | No | Share removed after reboot. |
ThrottleLimit | Integer | No | Limit the resources of the share. |
AsJob | Boolean (switch) | No | Create a Job to background process this command |