PowerTip: Use PowerShell to Create New File Share


Summary: Use Windows PowerShell to create a file share.

Hey, Scripting Guy! Question How can I use Windows PowerShell on my computer running Windows 8 to create a new file share?

Hey, Scripting Guy! Answer Open the Windows PowerShell console with Admin rights, then use the New-SmbShare function,
         and specify a file name and path:

New-SmbShare -Name fso -Path c:\fso

Comments (8)

  1. Ed Patterson says:

    The term ‘New-SmbShare’ is not recognized as the name of a cmdlet… Windows 7 in a 2008 R2 Domain using UNC for the path. \serverdrive$folder

  2. Matt says:

    Ed,

    That’s because you can’t use a UNC path. You are creating a share, not accessing one.

  3. Cl says:

    The term ‘new-smbshare’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check th
    e spelling of the name, or if a path was included, verify that the path is correct and try again.
    At line:1 char:13
    + new-smbshare < <<<
    + CategoryInfo : ObjectNotFound: (new-smbshare:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    What module is needed?

  4. Robin says:

    Cl, you’re likely using the wrong OS/PS version. Amazingly if you google the cmdlet name the official technet documentation will give you the information you need: Applies To: Windows 8.1, Windows PowerShell 4.0, Windows Server 2012 R2.

  5. Annoyed says:

    Robin, it would be "amazingly" helpful if you just provided the answer instead of telling people to use Google. It just saves the extra step and keeps the answer in one place.

    Alas "Google" told me that I cannot use New-SmbShare on Windows Server 2008 r2 or Windows 7.

    There was a link to this article instead:
    http://serverfault.com/questions/581585/create-network-shared-folder-using-powershell-on-windows-7

    Although it did seem slightly incomplete.

  6. KSchlichtherle says:

    New-SmbShare -Name fso -Path c:fso if i adapt it to my script i get the error message: Access denied

  7. Richard says:

    KSchlichtherle, right-click powershell and runas Administrator.

  8. Pat says:

    In PS v5 Get-SMBshare has changed to Get-Fileshare..New-SMBMapping to New-Fileshare

Skip to main content