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 cannot share individual files, only folders or disk volumes. Windows Server uses the Server Message Block (SMB) file-sharing protocol and File and Printer Sharing for Microsoft Networks (also known as the Server service) to perform file sharing.
Let’s go through 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 will 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’m sharing 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 navigate to the Sharing tab. You then click Advanced Sharing, enable Share this Folder, and then click Permissions to adjust the access control list (ACL) for the folder.
File Explorer’s proven way to share a folder in Windows Server.
You will notice that the default permission of the shared folder is to grant the special identity Everyone read access. Current best practice is actually to grant everyone (or at least authenticated users) full control.
The reason for these tips lies in how NTFS permissions combine with shared folder permissions. By setting shared folder permissions wide open, we are free to set more restrictive permissions in a granular way using NTFS security. Indeed, the effective authorization is the most restrictive authorization between the two access lists.
WindowsPowerShell
If you haven’t started mastering Windows PowerShell, 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 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 -Name scripts -Path ‘E:scripts’ -FullAccess
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 your Windows Server 2016 server has the File Server role, 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
If not, you can install the role quickly and easily with the following command:
Installer-WindowsFeature -Name FS-FileServer -IncludeAllSubFeature -IncludeManagementTools
You can start Server Manager from PowerShell by simply typing servermanager and hitting 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 simple as choosing New Share from the Tasks menu, then completing the New Share wizard.
You’ll notice that Server Manager’s New Share Wizard gives you more flexibility in creating shares than the two methods described previously. For example, you can create NFS (Network File System) shares compatible with Linux computers
Comments are closed.