Skip to main content
Jorge Bernhardt Jorge Bernhardt
  1. Posts/

How to create a Shared Folder using PowerShell

·182 words·1 min· 100 views · 5 likes ·
Get-Help Get-SmbShare Microsoft Microsoft Windows

In this post, I want to show how to create a shared folder using PowerShell. To do this, we can first check the PowerShell help to know the parameters of the New-SmbShare cmdlet To check the PowerShell help, we will use the Get-Help command with the following syntax.

New-SmbShare
To create a new share with PowerShell, use the New-SmbShare cmdlet with the following syntax:

New-SmbShare `
    -Name <String> `
    -Path <String> `
    -FullAccess <String[]> `
    -ChangeAccess <String[]> `
    -ReadAccess <String[]> `
    -Description <String>

In the case of a new directory, we create it with the New-Item cmdlet, run the PowerShell console as administrator, and then type:

New-Item `
    -Path 'c:\Parent-Directory\Sub-Directory' `
    -ItemType Directory

New-Item
Now, I can turn it into a shared folder using the New-SMBShare cmdlet. Run the PowerShell console as administrator, and then type:

New-SMBShare `
    Name SharedFolder `
    Path 'C:\Parent-Directory' `
    FullAccess Administrators `
    -ChangeAccess 'Server Operators' `
    -ReadAccess Users

As you can see in the Screenshot, using the Get-SmbShare cmdlet we can check the shared directories.

Shared Folder PowerShell

If you want to know more about the New-SmbShare cmdlet, check out this link.