Advanced sharing settings

Witold Jabłoński 0 Reputation points
2025-08-25T10:21:45.02+00:00

Hi,

I'm writing a script to automatically configure Windows Server 2025 without using GUI. Is there a way (preferably using PowerShell) to enable all the settings found in the Advanced Sharing Settings window?

Specifically, I'm looking to turn on the following options:

Private networks:

  1. Network Discovery (including the “Set up network-connected devices automatically” checkbox)
  2. File and Printer Sharing

Public networks:

  1. Network Discovery
  2. File and Printer Sharing

Domain networks:

  1. Network Discovery
  2. File and Printer Sharing

All networks:

  1. Public Folder Sharing

Best best regards

Windows for business | Windows Server | Networking | Network connectivity and file sharing

Locked Question. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Oldest
  1. Harry Phan 30,960 Reputation points Independent Advisor
    2025-08-25T11:18:48.4966667+00:00

    Dear Witold Jabłoński,

    Based on your requirements, here are the recommended PowerShell commands and approaches to enable the specified settings across different network profiles:

    A) Private, Public, and Domain Networks: Network Discovery & File and Printer Sharing

    You can enable these features using the following PowerShell commands:

    powershell

    # Enable Network Discovery
    netsh advfirewall firewall set rule group="Network Discovery" new enable=Yes
    
    # Enable File and Printer Sharing
    netsh advfirewall firewall set rule group="File and Printer Sharing" new enable=Yes
    

    These commands apply across all network profiles (Private, Public, Domain). If you need to target specific profiles, you can use the -Profile parameter with Set-NetFirewallRule.

    B) All Networks: Public Folder Sharing

    Public Folder Sharing settings are managed via registry keys. To enable sharing so that anyone with network access can read/write files in public folders:

    powershell

    Set-ItemProperty -Path "HKLM\SYSTEM\CurrentControlSet\Control\Lsa" -Name "ForceGuest" -Value 0
    

    Additionally, ensure the Public folder sharing service is running:

    powershell

    Set-Service -Name "LanmanServer" -StartupType Automatic
    Start-Service -Name "LanmanServer"
    

    C) Additional Considerations

    The “Set up network-connected devices automatically” checkbox is part of device discovery and may require enabling SSDP and UPnP services.

    Ensure the network profile is correctly set (Private, Public, Domain) using Get-NetConnectionProfile and Set-NetConnectionProfile.

    These settings may be affected by Group Policy or security baselines in managed environments.

    If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.

    Best regards,

    Harry Phan

    Was this answer helpful?

    1 person found this answer helpful.