So I came across a random issue when working on enabling PS remoting on a Windows 2012 R2 server with a customer then other day.
Issue
When trying to run Enable-PSRemoting, It would return an error saying: Unable to check the status of the firewall issue.
Resolution
The customer had removed the Windows Remote Management inbound rules in Windows Firewall, there are two ways to sort this.
Using Windows Firewall with Advanced Security GUI
1. Select Inbound Rules
2. Select New Rule from the action pane
3. In the New Rule Wizard, Select Predefined
4. Drop the Predefined list and select Windows Remote Management
5. Click Next
6. In Predefined Rules, select the two rules and click Next
7. Click Finish
Using PowerShell to Create Copy of Predefined Rule
If((Get-NetFirewallRule -Group "@FirewallAPI.dll,-30267" -ErrorAction SilentlyContinue | Measure).Count -gt 0)
{
Write-Output "Firewall Rule Already Exists"
}
Else
{
Write-Output "Firewall Rule Not Found"
New-NetFirewallRule -Group "@FirewallAPI.dll,-30267" -Name "WINRM-HTTP-In-TCP" -DisplayName "Windows Remote Management (HTTP-In)" -Direction Inbound -Description 'Inbound rule for Windows Remote Management via WS-Management. [TCP 5985]' -Profile Domain,Private -Enabled True -Action Allow -Protocol TCP -LocalPort 5985 -Program System -EdgeTraversalPolicy Block -LooseSourceMapping $False -LocalOnlyMapping $false
New-NetFirewallRule -Group "@FirewallAPI.dll,-30267" -Name "WINRM-HTTP-In-TCP-PUBLIC" -DisplayName "Windows Remote Management (HTTP-In)" -Direction Inbound -Description 'Inbound rule for Windows Remote Management via WS-Management. [TCP 5985]' -Profile Public -Enabled True -Action Allow -Protocol TCP -LocalPort 5985 -Program System -RemoteAddress LocalSubnet -EdgeTraversalPolicy Block -LooseSourceMapping $False -LocalOnlyMapping $false
}
Enable-PSRemoting -Force