PowerShell 3 makes it very easy to create a network share in Windows 8 and Windows Server 2012. PowerShell 3 brings with it a whole plethora of new commands. Most of the new cmdlets in PowerShell 3 are grouped together into modules that are easy to browse and load.
Creating a new network share is done with the SMBShare module. You do not need to load the module as you would have in previous versions of PowerShell. Cmdlets in unloaded modules are listed in the get-command results, and the module is loaded the first time one of the cmdlets is run.
How to Create a Network Share with PowerShell 3
To begin, you’ll need a folder to share. This is created with the New-Item cmdlet, instead of a cmdlet in the SMBShare module.
New-Item “C:\Shared" –type directory
If you are creating multiple levels at once (like “C:\NewRootFolder\NewChildFolder\NewShared” you can add the –force switch to make it create all necessary parent folders in the heirarchy)
Now that you have a folder that you want to share, you can turn it into a shared folder using the New-SMBShare cmdlet.
New-SMBShare –Name “Shared” –Path “C:\Shared” ` –ContinuouslyAvailable ` –FullAccess domain\admingroup ` -ChangeAccess domain\deptusers ` -ReadAccess “domain\authenticated users”
Create a Network Share with PowerShell – The Parameters
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.|
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.|
|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|
How To Change or Remove Network Shares with PowerShell
Here are the other cmdlets in the SMBShare module:
I hope this has helped you in your day!