How to create a file share in Windows Server 2016

The term “file sharing” in Windows Server is a bit of a misnomer. After all, you can’t share individual files, just folders or disk volumes. Windows Server uses the Server Message Block (SMB) file sharing protocol and the File and Printer Sharing for Microsoft Networks component (also known as the Server service) to perform file sharing.

Let’s take a look at a few ways to get the job done in Windows Server 2016. Remember that Windows has two types of permissions available for file system resources:

  • Shared folder permissions: These permissions control network access to a folder or disk volume
  • NTFS permissions: These permissions apply to local or remote access, and can be applied to individual files as well as folders or disk volumes

For simplicity, we’ll only focus on shared folder permissions in today’s tutorial.

In my examples, I’m running a Windows Server 2016 Technical Preview 5 domain controller, and I’ll share a folder in the D: scripts path that contains a number of Windows PowerShell .ps1 script files.

File explorer

The method familiar to most Windows system administrators is to right-click the target folder, select Properties from the context menu, and go to the Sharing tab. You then click Advanced Sharing, enable Share this folder, and click Permissions to adjust the access control list (ACL) for the folder.

The “tried and true” File Explorer method of sharing a folder in Windows Server.

You will notice that the default shared folder permission is to grant Read access to the Everyone special identity. The current best practice is actually to give everyone (or at least authenticated users) full control.

The reason for these tips is how NTFS permissions combine with shared folder permissions. By setting shared folder permissions widely open, we are free to set more restrictive permissions granularly using NTFS security. This is because the effective authorization is the most restrictive authorization between the two access lists.

Windows PowerShell

If you haven’t started mastering Windows PowerShell yet, you’re already late for the party. Open an elevated Windows PowerShell console session by right-clicking the PowerShell icon on the Start menu or taskbar and selecting Run as administrator from the context menu.

The New-SmbShare cmdlet is available in Windows Powershell v4 or later; of course, Windows Server 2016 includes Windows PowerShell v5.1. Try the following:
New-SmbShare -Scripts name -Path ‘E: scripts’ -FullAccess Everyone

You can actually do a lot with SMB file shares using PowerShell; let’s run Get-Command to see what’s available:

Get-Command -Noun SmbShare | Select-Object – Property name
Last name
—-
Get-SmbShare
New-SmbShare
Remove-SmbShare
Set-SmbShare

Server manager

As long as the file server role is installed on your Windows Server 2016 server, you can use Server Manager to create and manage file shares. Run the following PowerShell one-liner to determine if the role is installed:
Get-WindowsFeature -Name FS-FileServer

Otherwise, you can install the role quickly and easily with the following command:
Install-WindowsFeature -Name FS-FileServer -IncludeAllSubFeature -IncludeManagementTools

You can start Server Manager from PowerShell by simply typing servermanager and pressing Enter.

In Server Manager, select the File and Storage Services node, then Shares from the submenu. As the following screenshot shows, creating a new file share is as easy as choosing New Share from the Tasks menu and then completing the New Share wizard.

You will notice that the New Share Wizard in Server Manager gives you more flexibility in creating shares than the two methods described previously. For example, you can create Network File System (NFS) shares compatible with Linux computers