SkillPilotAI

PowerShell SmbShare module (3/3)

The last part of the SmbShare module: Revoke and Unblock take share and client access away again, Set-* changes shares, ACLs, bandwidth and the client/server SMB configuration (signing, encryption, SMB1), and Update refreshes multichannel info. This is the toolkit for hardening a Windows file server.

226.1 What it does, where it runs

  • Built into Windows 10/11 and Windows Server; PowerShell 5.1 and 7.
  • All 13 cmdlets of this part (verbs Set, Revoke, Unblock, Update) change a setting or permission and need admin.
  • Set-SmbShare alias: ssmbs.
  • On the office PC only Get-Command and Get-Help ran; even Get-Smb*Configuration was skipped because it reveals the office signing/encryption policy.
PowerShell
Get-Command -Module SmbShare `  -Verb Set,Revoke,Unblock,Update |  Measure-ObjectGet-Help Set-SmbShare
Output
$ Get-Command -Module SmbShare -Verb Set,Revoke,Unblock,Update | Measure-ObjectCount    : 13$ Get-Help Set-SmbShare   (trimmed)SYNTAX    Set-SmbShare [-Name] <string[]> [[-ScopeName] <string[]>] [-SmbInstance {Default | CSV | SBL | SR}] [-Description <string>] [-ConcurrentUserLimit <uint32>] [-CATimeout <uint32>] ALIASES    ssmbsREMARKS    Get-Help cannot find the Help files for this cmdlet on this computer. It is displaying only partial help.

226.2 How it works: share access entries

Share access: Revoke, Block, Unblock
  1. 1.Share \\fs01\reports: Allow Asha (Change), Allow Ravi (Read)

  2. 2.Ravi's tree connect goes through the switch: access granted

  3. 3.Admin: Revoke-SmbShareAccess Ravi removes all his Allow entries

  4. 4.Ravi's next tree connect: ACCESS_DENIED; Asha still works

  5. 5.Block-SmbShareAccess would add a Deny entry instead

  6. 6.Unblock-SmbShareAccess removes only Deny entries

Block + Revoke, then Unblock = still no access: there is no Allow entry left. Use Grant-SmbShareAccess.

CmdletAdds / removesEntry type
Grant-SmbShareAccessAddsAllow
Revoke-SmbShareAccessRemoves all of a trustee'sAllow
Block-SmbShareAccessAddsDeny
Unblock-SmbShareAccessRemovesDeny

226.3 Revoke and Unblock cmdlets

  • Revoke-SmbShareAccess (8) / Unblock-SmbShareAccess (8): -Name (share), -AccountName (trustee), -ScopeName (cluster), -SmbInstance, -InputObject, -Force.
  • Revoke-SmbClientAccessToServer (6): removes an SMB over QUIC access rule given earlier with Grant-SmbClientAccessToServer.
  • Unblock-SmbClientAccessToServer (6): allows a client that was blocked earlier; client identified by -IdentifierType SHA256 or ISSUER.
PowerShell
Revoke-SmbShareAccess -Name "VMFiles" `  -AccountName "Contoso\Contoso-HV2$" -ForceUnblock-SmbShareAccess -Name "VMFiles" `  -AccountName "Contoso\Guest" -ForceRevoke-SmbClientAccessToServer `  -Name "Server01" -IdentifierType "SHA256" `  -Identifier "ClientHash"$params = @{    Name = "Server01"    IdentifierType = "ISSUER"    Identifier = "CN=MyCertificateIssuer"    Force = $true}Unblock-SmbClientAccessToServer @params
Output
PS C:\>Revoke-SmbShareAccess -Name "VMFiles" -AccountName "Contoso\Contoso-HV2$" -ForceName                    ScopeName               AccountName             AccessControlType       AccessRightVMFiles                 Contoso-SO              Contoso\Administrator   Allow                   FullVMFiles                 Contoso-SO              Contoso\Contoso-HV1$    Allow                   Full

226.4 Set-SmbShare (22)

  • Changes properties of an existing share; without -Force it shows a Confirm prompt.
  • Options: -Description, -ConcurrentUserLimit, -EncryptData, -CompressData, -FolderEnumerationMode AccessBased, -CachingMode (offline files), -LeasingMode, -ContinuouslyAvailable.
  • -SecurityDescriptor sets the whole share permission as one SDDL string.
  • -EncryptData on a share encrypts only that share's traffic, not the whole server.
PowerShell
Set-SmbShare -Name "VMFiles" `  -EncryptData $TrueSet-SmbShare -Name "VMFiles" `  -EncryptData $True -Force
Output
Set-SmbShare -Name "VMFiles" -EncryptData $TrueConfirmAre you sure you want to perform this action?Performing operation 'Modify' on Target 'Contoso-SO,VMFiles'.[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"):

226.5 Set-SmbPathAcl, Set-SmbBandwidthLimit, Update-SmbMultichannelConnection

  • Set-SmbPathAcl (4): copies the share permissions into the folder's NTFS/ReFS ACL so both match.
  • Set-SmbBandwidthLimit (4): max bytes/sec per category (Default, VirtualMachine, LiveMigration, StorageReplication).
  • Update-SmbMultichannelConnection (3): client refreshes network interface info from connected servers; -ServerName for one server.
PowerShell
Set-SmbPathAcl -ShareName "Share01"Set-SmbPathAcl -ShareName "Share01" `  -ScopeName "SOFS01"Set-SmbBandwidthLimit -Category Default `  -BytesPerSecond 100MBSet-SmbBandwidthLimit `  -Category LiveMigration -BytesPerSecond 1GBUpdate-SmbMultichannelConnection `  -ServerName "Contoso-SO"

226.6 Set-SmbClientConfiguration (46)

PowerShell
Set-SmbClientConfiguration `  -ConnectionCountPerRssNetworkInterface 8 `  -Confirm:$falseSet-SmbClientConfiguration `  -EncryptionCiphers `  "AES_128_GCM, AES_256_GCM" -Confirm:$false
GroupExamples
Security (6)-RequireSecuritySignature, -EnableSecuritySignature, -RequireEncryption, -BlockNTLM, -EnableInsecureGuestLogons
Audit (3)-AuditInsecureGuestLogon, -AuditServerDoesNotSupport* (2)
Version (2)-Smb2DialectMin, -Smb2DialectMax
QUIC (3)-EnableSMBQUIC, -SkipCertificateCheck, -ForceSMBEncryptionOverQuic
Cache (8)-DirectoryCache*, -FileInfoCache*, -FileNotFoundCache*
Timeout (5)-SessionTimeout, -KeepConn
Speed (7)-EnableMultiChannel, -EnableLargeMtu, -EnableBandwidthThrottling
Compression / locks-RequestCompression, -CompressibilitySamplingSize, -UseOpportunisticLocking, -EnableMailslots

226.7 Set-SmbServerConfiguration (65)

Server: EncryptData + RejectUnencryptedAccess
  1. 1.Admin: Set-SmbServerConfiguration -EncryptData $true

  2. 2.RejectUnencryptedAccess is true

  3. 3.Windows 11 laptop (SMB 3.1.1) sends an encrypted request

  4. 4.Request reaches the file server: allowed

  5. 5.Old client (SMB 2.1) cannot encrypt

  6. 6.Server denies it: Access denied

Check old clients before enforcing encryption.

PowerShell
Set-SmbServerConfiguration `  -MaxChannelPerSession 16 -Confirm:$false$Parameters = @{    RequireSecuritySignature = $true    EnableSecuritySignature = $true    EncryptData = $true    Confirm = $false}Set-SmbServerConfiguration @ParametersSet-SmbServerConfiguration -AutoShareServer `  $false -AutoShareWorkstation $false `  -Confirm:$falseSet-SmbServerConfiguration `  -EnableSMB1Protocol $false -Confirm:$false
GroupExamples
Sign/encrypt (6)-RequireSecuritySignature, -EncryptData, -RejectUnencryptedAccess
Protocol (5)-EnableSMB1Protocol, -EnableSMB2Protocol, -Smb2DialectMin/Max, -EnableSMBQUIC
Audit (5)-AuditSmb1Access, -AuditClient*
Auth (5)-SmbServerNameHardeningLevel
Shares (7)-AutoShareServer, -AutoShareWorkstation, -ServerHidden
Limits (10)-Smb2Credits*, -MaxChannelPerSession, -MaxMpxCount/-MaxWorkItems (SMB1 only)
Leasing (4)-EnableLeasing, -EnableOplocks, -OplockBreakWait
Validate (4)-ValidateShareScope, -ValidateAliasNotCircular
Other-EnableForcedLogoff, -KeepAliveTime, -CachedOpenLimit, -EnableMultiChannel
PowerShell
Set-SmbServerAlternativePort `  -TransportType QUIC -Port 1$params = @{    Name = "2022-ae-02.corp.contoso.com"    Thumbprint = "88032B3551FAF7DE26EFFFF814AA086E3DBD2A4F"    StoreName = "My"    Flags = "AllowNamedPipe"}Set-SmbServerCertificateMapping @paramsSet-SmbClientCertificateMapping `  -Thumbprint "1234567890abcdef" `  -IssuerName "CN=NewIssuerName"
  • SMB over QUIC Set cmdlets: Set-SmbServerAlternativePort (6), Set-SmbServerCertificateMapping (9, -Flags AllowNamedPipe enables named pipes on the QUIC endpoint), Set-SmbClientCertificateMapping (6).

226.8 Linux equivalent: Samba net conf

WindowsSamba (lab)
Set-SmbShare (read only)net conf setparm reports 'read only' yes
Revoke-SmbShareAccessnet conf setparm reports 'valid users' asha (ravi removed)
Set-SmbShare -EncryptDatanet conf setparm reports 'smb encrypt' required (shown as server smb encrypt)
Set-SmbClientConfiguration -RequireEncryptionsmbclient --client-protection=encrypt
Set-SmbServerConfiguration -RequireSecuritySignaturenet conf setparm global 'server signing' mandatory
Terminal
net conf setparm reports 'read only' yessmbclient //192.168.246.10/reports \  -U asha%LabPass226 \  -c 'put /etc/hostname asha2.txt'net conf setparm reports 'valid users' ashasmbclient //192.168.246.10/reports \  -U ravi%LabPass226 -c lsnet conf setparm reports 'smb encrypt' \  requiredsmbclient //192.168.246.10/reports \  -U asha%LabPass226 -m SMB2_10 -c lssmbstatus -Snet conf setparm global 'server signing' \  mandatorysmbcontrol smbd reload-configsmbstatus -b
Output
[client] $ smbclient //192.168.246.10/reports -U asha%LabPass226 -c 'put /etc/hostname asha2.txt'NT_STATUS_ACCESS_DENIED opening remote file \asha2.txt[client] $ smbclient //192.168.246.10/reports -U ravi%LabPass226 -c lstree connect failed: NT_STATUS_ACCESS_DENIED[client] $ smbclient //192.168.246.10/reports -U asha%LabPass226 -m SMB2_10 -c lstree connect failed: NT_STATUS_ACCESS_DENIED[srv] $ smbstatus -SService      pid     Machine       Connected at                     Encryption   Signingreports      139     192.168.246.20 Mon Nov  9 14:54:31 2026 UTC     AES-128-GCM  -[client] $ smbclient //192.168.246.10/reports -U asha%LabPass226 --client-protection=encrypt -c lsEncryption required and server doesn't support SMB3 encryption - failing connect(server smb encrypt off at that moment)[srv] $ smbstatus -b   (before server signing = mandatory)179     asha         asha         192.168.246.20 (ipv4:192.168.246.20:60750) SMB3_11           -                    partial(AES-128-GMAC)[srv] $ smbstatus -b   (after)201     asha         asha         192.168.246.20 (ipv4:192.168.246.20:57102) SMB3_11           -                    AES-128-GMAC

226.9 Common mistakes

  • Expecting Unblock to restore access after Block + Revoke: it removes only Deny entries; Grant is needed.
  • Thinking Set-SmbShare -EncryptData encrypts the whole server; server-wide needs Set-SmbServerConfiguration -EncryptData $true.
  • Turning on RejectUnencryptedAccess without checking old SMB 2.x clients: they get Access denied.
  • Changing settings without first reading the current value with Get-Smb*Configuration.

226.10 Interview tips

  • Securing a file server: disable SMB1 and require signing with Set-SmbServerConfiguration.
  • Encrypt sensitive shares with Set-SmbShare -EncryptData; check RejectUnencryptedAccess impact on old clients.
  • Share access: Grant/Revoke (Allow) and Block/Unblock (Deny); align folder ACL with Set-SmbPathAcl.
  • Always read the current value with Get-* before changing.
  • Samba parallels: net conf setparm (read only, valid users, smb encrypt, server signing).