SMB File Shares on a Windows VPS: Permissions, Access Control, and Automation

SMB shares on a Windows VPS tend to grow by accident. Someone creates a folder for a project, shares it, grants Full Control to Everyone because the job needed to move forward, and three years later nobody knows which accounts can reach what. Sorting this out is mostly a matter of understanding that share permissions and NTFS permissions are two separate layers, and the effective access is the more restrictive of the two.

This article walks through the current permission model, the PowerShell commands to inspect and correct it, and a scripted way to apply a consistent set of permissions across a tree. If the server is new, pair this with the platform notes on windows-vps.org for the storage layout you are sharing from.

The Two Layers: Share Permissions vs NTFS

Share permissions are set on the share itself and apply only to network access. NTFS permissions are set on the file system objects and apply to both local and network access. When the two disagree, Windows takes the most restrictive result.

Layer Applies to Best practice
Share permissions Network sessions only Grant Domain Users (or a group) Change, Everyone is wrong
NTFS permissions Local and network Fine-grained control, the real security boundary
Effective access Combined result Intersection of both, audit with tooling

The simplest working rule: give the share Change for the group that should use the folder, then handle the fine distinctions entirely in NTFS. This avoids a situation where a correct NTFS ACL is silently defeated by an over-wide share entry.

Full Control on the share is rarely needed and should be treated as a red flag when you find it. It means anyone reaching the share can change the share permissions themselves, which is a permission management problem no NTFS ACL can fix.

Inspecting Existing Shares and ACLs

Start by listing what is shared and who can reach it. The built-in cmdlets are enough for most inventories and do not require the SMB share management tools.

  • Get-SmbShare | Select Name, Path, Description, EncryptData
  • Get-SmbShareAccess -Name Projects
  • Get-Acl 'C:\Shares\Projects' | Format-List
  • Get-ChildItem 'C:\Shares\Projects' -Recurse | Get-Acl | Select Path, AccessToString

Look for the classic problems: a share granted to Everyone, NTFS inheriting from a parent that grants more than the folder needs, and service accounts listed individually instead of through a group. Each of those is maintenance debt that grows with every new employee.

For a quick report across all shares, export the ACLs to CSV and review them offline: Get-SmbShare | ForEach-Object { Get-SmbShareAccess -Name $_.Name } | Export-Csv C:\Admin\shareacls.csv. That output is also useful evidence during a permissions review.

Designing an NTFS Group Structure

Before writing any script, decide on the groups. A workable pattern for a small server uses three groups per shared area: readers, contributors, and owners, with each group mapped to a different NTFS level.

  1. Create groups with a clear prefix, e.g. SH_Projects_RO, SH_Projects_RW, SH_Projects_FC.
  2. Assign users to groups, never to folders directly.
  3. Apply ACLs once at the folder root and let inheritance handle descendants.

Create the groups with New-LocalGroup -Name SH_Projects_RW -Description "Projects write access" and add members with Add-LocalGroupMember. On a domain-joined host, swap these for New-ADGroup and Add-ADGroupMember.

Applying ACLs with PowerShell: icacls and Set-Acl

Two tools do most of the work. icacls is fast, well documented, and handles inheritance flags explicitly. Set-Acl works with .NET security objects when you need conditional logic. For repeatable provisioning, prefer icacls with an explicit ACL reset.

icacls "C:\Shares\Projects" /inheritance:r /grant:r "SH_Projects_FC:(OI)(CI)F" "SH_Projects_RW:(OI)(CI)M" "SH_Projects_RO:(OI)(CI)RX"
icacls "C:\Shares\Projects" /grant:r "SYSTEM:(OI)(CI)F" "Administrators:(OI)(CI)F"

The /inheritance:r flag removes inherited entries first, which is essential when the folder sits under a permissive parent. The (OI)(CI) flags push the entry to files and folders below, so one command covers the whole tree.

Check the result before moving on: icacls "C:\Shares\Projects". Anything you did not explicitly grant should be gone. If an inherited entry survives, you missed a parent ACL or the command targeted the wrong path.

Scripting a Repeatable Share Provisioning Routine

A provisioning function takes a folder name and a group prefix, then does the whole job: create the directory, create the share, apply NTFS, and set the share permission. That is the unit of work you want to keep in source control.

param($Name, $Path, $GroupPrefix)
New-Item -ItemType Directory -Path $Path -Force | Out-Null
New-SmbShare -Name $Name -Path $Path -FullAccess "$GroupPrefix`_FC" -ChangeAccess "$GroupPrefix`_RW" -ReadAccess "$GroupPrefix`_RO"
icacls $Path /inheritance:r /grant:r "$GroupPrefix`_FC:(OI)(CI)F" "$GroupPrefix`_RW:(OI)(CI)M" "$GroupPrefix`_RO:(OI)(CI)RX" "SYSTEM:(OI)(CI)F" "Administrators:(OI)(CI)F"

Run the script against a test folder before it touches production. The New-SmbShare cmdlet’s mapping of FullAccess to Change to Read on the share is deliberate: each group gets exactly the share level matching its NTFS intent.

Log every run to a file with the timestamp, target path, and the ACL applied. When a permission complaint arrives six months later, the log answers “who changed this and when” without guesswork.

Verifying Effective Access

ACLs that look right in text can still produce the wrong result. Verify effective access with a real account, not the account you are logged in as.

  • Get-SmbShareAccess -Name Projects | Format-Table
  • Get-Acl 'C:\Shares\Projects' | Select-Object -ExpandProperty Access | Format-Table IdentityReference, FileSystemRights, AccessControlType
  • Map the share from a test session: net use Z: \\localhost\Projects /user:testreader
  • Attempt a write as the reader account and confirm it is denied

The write test is the one that matters. A reader account that can create a file means either the NTFS entry is too loose or the share grants Change, and the mapping command will show you which.

Repeat the test for a contributor and an owner. Three accounts covering read, write, and full control prove the three-group model works exactly as designed.

Auditing and Pruning Over Time

Permissions drift back toward chaos unless something prunes them. Schedule a monthly review that flags direct user entries, orphaned SIDs, and shares granted to Everyone.

  • Get-ChildItem C:\Shares -Recurse | Get-Acl | Where-Object { $_.AccessToString -match 'Everyone' }
  • Get-SmbShareAccess | Where-Object AccountName -eq 'Everyone'
  • Get-LocalGroupMember SH_Projects_RW | Where-Object Name -NotMatch '\\'

Orphaned SIDs appear as raw values like S-1-5-21-... instead of a name. Those represent deleted accounts whose access never got cleaned up, and removing them is a small but real security win. Store the review output next to the provisioning log so the history is complete, and note the results with the contact page if you want platform-specific guidance on the share layout in use.

Leave a Comment