Skip to content

Instantly share code, notes, and snippets.

@AlexanderMityaev
Created May 26, 2025 04:10
Show Gist options
  • Select an option

  • Save AlexanderMityaev/01cef3adcae5f02014a3681f88b38641 to your computer and use it in GitHub Desktop.

Select an option

Save AlexanderMityaev/01cef3adcae5f02014a3681f88b38641 to your computer and use it in GitHub Desktop.
Win10/11 SMB easy sharing
# Run as Administrator
# 1. Set network to Private
Get-NetConnectionProfile | Set-NetConnectionProfile -NetworkCategory Private
# 2. Enable Network Discovery and File/Printer Sharing
Set-NetFirewallRule -DisplayGroup "Network Discovery" -Enabled True -Profile Private
Set-NetFirewallRule -DisplayGroup "File and Printer Sharing" -Enabled True -Profile Private
# 3. Disable password-protected sharing (optional, for ease of access)
$regPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa"
Set-ItemProperty -Path $regPath -Name "limitblankpassworduse" -Value 0
# Or enable password-protected sharing (safer):
# netsh advfirewall firewall set rule group="File and Printer Sharing" new enable=Yes
# netsh advfirewall firewall set rule group="Network Discovery" new enable=Yes
# 4. Create a local user (optional, use same creds on all machines)
$User = "shareduser"
$Password = ConvertTo-SecureString "StrongPassword123" -AsPlainText -Force
New-LocalUser $User -Password $Password -FullName "Shared Access User" -PasswordNeverExpires -UserMayNotChangePassword
Add-LocalGroupMember -Group "Users" -Member $User
# 5. Create and share a folder
$folder = "C:\Shared"
New-Item -ItemType Directory -Path $folder -Force
net share PublicShare="$folder" /GRANT:Everyone,FULL
# Optional: Share a printer by name
# Add-Printer -Name "SharedPrinter" -DriverName "Your Printer Driver" -PortName "YourPort"
# Set-Printer -Name "SharedPrinter" -Shared $true -ShareName "OfficePrinter"
# Optional: View SMB1 component status
# Get-SmbServerConfiguration | Select EnableSMB1Protocol
Write-Host "Setup complete. Restart may be required." -ForegroundColor Green
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment