Configuring and managing shared folders
The daily administrator's job is to collaborate with your team. Your team might create documents that only team members can share, or you might work with a remote team member who needs access to your team's files. Because of this type of collaboration and the requirements for this, you must understand how to manage shared folders in a network environment.
A user can connect to a shared folder over a network and access the folders and files that are in the shared folder. Shared folders can contain applications, public data, or a user's personal data. By providing a central location for shared folders, you enable the following features:
- Simplification of administrative management
- Ease in backing up data
- Consistent location and availability
- User familiarity
In this section, we will learn about the various methods you can use to share folders, along with the effect this has on file and folder permissions when you create shared folders on an NTFS formatted partition.
When an administrator shares a folder, the administrator makes its content available on the network to multiple users. The administrator can limit who can access the shared folder and what type of shared permissions they have. Additionally, the administrator can limit the number of users who can access the share at the same time and if an offline copy will be created automatically on their computer.
Shared folders maintain a separate set of permissions from the file system permissions, which means that the administrator can set share permissions, even if the administrator shares a folder on the FAT file system. The same share permissions apply to all shared content. This behavior is different from file system permissions, where the administrator can set permissions for each file individually.
The administrator can use these permissions to provide an extra level of security for files and folders that you make available on your network. The administrator can share the same folder multiple times by using a different share name and other share settings for each creation.
After the administrator shares a folder, all users on the network will see the share name. But only the users with Read permissions can view the content inside that share. Windows 10 restricts folder sharing to members of the Administrators group. If a user is not a member of the Administrators group, then the user must provide administrative credentials in the User Account Control (UAC) dialog box.
File and printer sharing are disabled by default. When you share the first folder on a Windows 10 device, Windows 10 turns on file and printer sharing automatically. This setting remains turned on, even if you remove all shared folders. You can configure it manually in Advanced sharing settings in the Control Panel.
Now, let's take a look at shared folder permissions. As you can see, besides files and folder permissions, you can also set permissions on shares. Share permissions are permissions for users or groups so they can access the folder before they can access the files.
Understanding shared folder permissions
When you share a folder, you must configure the permissions that a user or group will have when they connect to the folder through the share. This is called sharing permissions. The following are three options for sharing permissions:
- Read: The users can view the content, but they cannot modify or delete it.
- Change: The users can also modify, delete, and create content, but they cannot modify permissions. This permission also includes the Read permission.
- Full Control: The users can perform all actions, including modifying the permissions. This permission also includes the Change permission.
Besides the previously stated sharing permissions, you also have the basic sharing permissions. These permissions are simplified and can have one of two options, which are given as follows:
- Read: The users can open but cannot modify or delete a file.
- Read/Write: This is the Full Control option. The users can open, modify, or delete a file and modify permissions.
Now that you know about the five different shared folder permissions, in the next section, you will learn how you can view which permissions a shared folder has.
Viewing shared folders
Windows 10 creates several shared folders by default. You can view all shared folders in the Computer Management console by clicking the Shared Folders node. You can also run the following command:
net view \\localhost /all
We can also run the following command on a PowerShell cmdlet:
Get-SmbShare
The following screenshot shows the output after executing the net view \\localhost /all command:
In the previous screenshot, you can see the output of both commands. The first output is the command line, while the second output is the PowerShell cmdlet.
Important Note
In older Windows versions, you could recognize shared folders in File Explorer because there was a different icon for folders that were being shared compared to folders that were not being shared. In File Explorer within Windows 10, the same icon is used, regardless of whether a folder is shared or not.
Now, you know how to view which permissions a shared folder has. In the next section, we will create a shared folder and the tools needed to create such a folder.
Creating shared folders
Users can connect to a shared folder most commonly over the network by using its Universal Naming Convention (UNC) address. The UNC address contains the name of the computer that is hosting the folder and the shared folder name, separated by a backward slash (\) and preceded by two backward slashes (\\). For example, the UNC name for the Accounting shared folder on the CAT-CL7 computer in the Theorange.cat domain would be \\CAT-CL7.theorange.cat\Accounting. You can share folders in several ways, as follows:
- Shared Folders snap-in
- File Explorer
- Command Prompt
- PowerShell cmdlets
In the next few sections, you will learn how you can use the previously mentioned ways to share a folder.
Shared Folders snap-in
You can use the Shared Folders snap-in to manage a computer's file shares centrally. You can use this snap-in to create file shares, set permissions, and view and manage open files and the users who can connect to a computer's file shares. Additionally, you can view the properties for the shared folder, which would allow you to perform actions such as specifying file permissions.
Let's create a share and give permissions using the Shared Folders snap-in:
- Right-click on Start.
- Click Computer Management | Shared Folders | Shares buttons. The following screenshot shows the computer management window:
- Right-click in the middle pane, or right-click on Shares.
- Click on New Share….
- In the Create a Shared Folder Wizard, click Next:
- Click on Browse…, go to the folder you want to share, and click OK:
- Click on Next, as shown in the following screenshot:
- Type in the share name and description and choose the correct offline settings:
- Click on Next.
- Choose the correct permissions for the shared folder or customize the permissions by clicking Customize permissions:
- Click on Finish.
- Then, click on the next Finish button:
With that, you have successfully created a shared folder by using the Shared Folders snap-in:
Now that we've created a share via the Shared Folders snap-in, we can do the same via File Explorer.
File Explorer
You can use File Explorer to share a folder using the Share with option from the shortcut menu or via the ribbon.
Let's create a shared folder using File Explorer with the Share with option:
- Open File Explorer and go to the folder you want to share.
- Click on the Share tab in the ribbon.
- In the Share with box, choose a user:
- In the Network access wizard, click on Yes, share the items.
- If this is your first time doing this, then the Network discovery and file sharing dialog box will open. Choose the appropriate option for your environment: No, make the network that I am connected to a private network or Yes, turn on network discovery and file sharing for all public networks. The Network discovery and file sharing window is as follows:
- The folder will now be set up so that it can be shared with the user.
- To check if the folder is being shared, open the Properties dialog box and click on the Sharing tab:
With that, you have successfully created a share with File Explorer. Next, we will do this with the command line.
Command line
You can share a folder by using the net share command, as shown here:
net share IT=C:\Data\Department\IT
The previous command will create the IT share, which uses the IT share name, and which grants all users Read permissions. You can specify additional parameters when creating a share, some of which are as follows:
- /Grant:user permission: This allows you to specify Read, Change, or Full share permissions for the specified user.
- /Users:number: This allows you to limit the number of users who can connect to the share.
- /Remark:"text": This allows you to add a comment to the share.
- /Cache:option: This allows you to specify the caching options for the share.
- sharename /Delete: This allows you to remove an existing share.
Besides using Command Prompt, you can use PowerShell as well.
In the following screenshot, you can see an example of how to use the net share command with some optional parameters:
PowerShell
PowerShell includes several cmdlets that you can use to manage shares. The following example illustrates the cmdlet for creating a share:
New-SmbShare –Name "Global IT" –Path C:\Data\Department\IT
The following points list additional PowerShell commands that you can use to manage shares:
- Get-SmbShare: This retrieves a list of the computer's existing shares.
- Set-SmbShare: This modifies an existing share.
- Remove-SmbShare: This removes an existing share.
- Get-SmbShareAccess: This retrieves a share's permissions.
- Grant-SmbShareAccess: This sets share permissions.
In the following screenshot, you can see an example of the New-SmbShare cmdlet being used with some optional parameters:
With that, you learned how you can create, modify, or delete shares in different ways. Next, you will learn what you can do with this shared folder properties and how you can configure them.
Shared folder properties
You can configure the properties of a shared folder when you create a share or when you modify shared folder properties. The properties that you can configure from a shared folder are as follows:
- The way your users can view and connect to a share
- The number of users that can access a share simultaneously
- Which share permissions will be effective for your users
- The offline settings for the share data
You can configure these three properties in several ways, as follows:
- Advanced Sharing
- The net share command
- The PowerShell cmdlets, namely New-SmbShare and Set-SmbShare
There are many ways to connect to a shared folder by using the File Explorer, command line, and by using PowerShell. Let's take a look.
Advanced Sharing
From the Advanced Sharing option, which you can find in the Sharing tab in the Folder properties window, you can configure the following parameters: Share name, Number of simultaneous users, Caching, and Permissions. The following screenshot shows the Advanced Sharing window:
From the preceding screenshot, you can see various fields. Let's take a look at them in more detail:
- Share name: Each share must have a share name, and it must be unique for each Windows 10-based computer. The share name can be any string that does not contain special characters, and it is part of the UNC path.
You can share the same folder multiple times and with different properties, but each share name must be unique. If the share name ends with a dollar sign ($), then the share is hidden and not visible on the network. However, you can connect to it if you know the share name and have the appropriate permissions.
- Number of simultaneous users: This limits the number of users that can have an open connection to the share. The connection to the share is open when a user accesses the share for the first time, and it closes automatically after a period of inactivity. The default value in Windows 10 is no more than 20 users. However, you can set this to a lower number.
- Caching: You can control which of the share's files and programs are available to offline users, or those who do not have network connectivity. You can configure files as follows:
From the previous screenshot, you can see the various options that you can choose from: Only the files and programs that users specify are available offline, No files or programs from the shared folder are available offline, and All files and programs that users open from the shared folder are automatically available offline.
- Permissions: You can configure shared folder permissions that Windows uses in conjunction with file system permissions when a user tries to use a shared folder to access data over a network. Shared folder permissions can allow Read, Change, or Full control permissions, as shown in the following screenshot:
If you try to use a share name that is already in use on the computer, Windows 10 will provide you with an option to stop sharing an old folder and use the share name to share the current folder. If you rename a folder that is being shared currently, you won't receive a warning. However, the folder will no longer be shared.
Important Note
If you share a folder by using Network File and Folder Sharing, you can share a folder only once, and you cannot configure its properties manually. The share name is set automatically and is the same as the folder name. The share permissions, number of simultaneous users, and caching properties retain the same value.
We'll look at the command-line option next.
Command line
With the following cmd command, you can view the shared folder properties for a share. In this example, the shared folder is named Accounting:
net share Accounting
The output from this command will be as follows:
As shown in the previous screenshot, not that much information is given about this share, only Share name, Path, Remark, Maximum users, Users, Caching, and Permission. When you are using PowerShell, then you will see more information about a share.
PowerShell
With the following PowerShell cmdlet, you can view shared folder properties for a share. In this example, the shared folder is named Data:
Get-SmbShare –Name Data | Format-List –Property *
The output of the preceding command can be seen in the following screenshot:
In this section, you learned how you can configure and maintain shared folders in a Windows 10 environment. There are benefits for an administrator to centrally manage shared folders, such as ease of use for backups and simplified management.
You also learned about the different types of shared folder permissions and how you can view shared folders. Then, you learned how to create a shared folder through the Shared Folders snap-in and how to give permissions to users. You can modify the properties from a shared folder by modifying the caching settings, permissions, number of simultaneous connected users, and, of course, the name of the share.