The term “file share” in Windows Server is a bit of a misnomer. After all, you can’t share individual files, but only 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 review some ways to get the job done in Windows Server 2016. Recall 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 focus only 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 out a folder in the path D:scripts that contains a number of Windows PowerShell .ps1 script files.
The method that’s familiar to most Windows systems administrators is to right-click the target folder, select Properties from the shortcut menu, and navigate to the Sharing tab. You then click Advanced Sharing, enable Share this folder, and click Permissions to adjust the folder’s access control list (ACL).
The “tried and true” File Explorer method for sharing a folder in Windows Server.
You’ll note that the default shared folder permission is to grant the Everyone special identity Read access. The current best practice is actually to grant Everyone (or at least Authenticated Users) Full Control.
The reason for this guidance lies in how NTFS permissions combine with shared folder permissions. By setting the shared folder permissions wide open, we are free to set more restrictive permissions granularly using NTFS security. That’s because the effective permission is the most restrictive permission between the two access lists.
If you haven’t begun mastering Windows PowerShell, then you’re already late to the party. Open an elevated Windows PowerShell console session by right-clicking the PowerShell icon in the Start menu or taskbar and selecting Run as Administrator from the shortcut 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 -Name scripts -Path ‘E:scripts’ -FullAccess Everyone
You can actually do a lot with SMB file shares by using PowerShell; let’s run Get-Command to see what’s available:
Get-Command -Noun SmbShare | Select-Object -Property Name
As long as your Windows Server 2016 server has the File Server role installed, you can use Server Manager to create and manage file shares. Run the following PowerShell “one-liner” to determine whether the role’s installed:
Get-WindowsFeature -Name FS-FileServer
If not, then 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 simply by typing servermanager and pressing Enter.
In Server Manager, select the File and Storage Services node, and then Shares in the submenu. As shown in the following screenshot, creating a new file share is as easy as choosing New Share from the Tasks menu and then completing the New Share Wizard.
You’ll note that the Server Manager New Share Wizard gives you more flexibility in creating shares than the two previously described methods. For instance, you can create Network File System (NFS) shares that are compatible with Linux computers