PowerShell: Turn on File Sharing

By Xah Lee. Date: .

Enable File and Printer Sharing for Private Networks

Turn on file sharing

Set-NetFirewallRule -DisplayGroup "File and Printer Sharing" -Profile Private -Enabled True

Turn off file sharing

Set-NetFirewallRule -DisplayGroup "File and Printer Sharing" -Profile Private -Enabled False

Turn On/Off Network Discovery

This allows the Windows machine to be listed when other device connects to the network.

# For Private profile
Set-NetFirewallRule -DisplayGroup "Network Discovery" -Profile Private -Enabled False