Showing posts with label Firewall. Show all posts
Showing posts with label Firewall. Show all posts

Friday, 21 May 2021

Powershell Script to reset Windows 2016+ Remote Desktop Host firewall

This a quick script to reset a Windows Servers firewall and insert the fix for cleaning down the rules when user logs off on a Remote Desktop Host.

#Powershell
Remove-Item "HKLM:\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\RestrictedServices\Configurable\System"
New-Item "HKLM:\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\RestrictedServices\Configurable\System"
Remove-Item "HKLM:\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\RestrictedServices\AppIso\FirewallRules"
New-Item "HKLM:\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\RestrictedServices\AppIso\FirewallRules"
(New-Object -ComObject HNetCfg.FwPolicy2).RestoreLocalFirewallDefaults()
New-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy' -Name  'DeleteUserAppContainersOnLogoff' -Value '1' -PropertyType 'DWORD' –Force
#EOF

Tuesday, 9 February 2021

Remote Desktop Host firewall is filled with multiple firewall rules

Every time a user connects in to the RDH,  firewall rules are made for the users Windows Apps but never cleaned down.

This can have a few issues linked to it like Black screening on the host or the start menu not displaying but depending on the Windows version you mileage will vary.  In all case it can lead to slowing down of the system.

For Windows Server 2016 you will need to confirm the following update is installed KB4467684,  Server 2019 should already be able to do this but I would bring it in line with all updates to just be sure.

Make a GPO if you have more then 2 RDH and put this Key in place.

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy
DeleteUserAppContainersOnLogoff (DWORD)
Value: 1

No Microsoft document appears to back this up but it is listed in a few updates and talked about as a known issue under KB4467684