Tags

, ,


Some time ago I wrote a fairly-extensive post about an issue I was seeing with failure to register PowerShell Remoting Endpoints (PSSessionConfigurations) when enabling PSRemoting via Group Policy.

I never did solve the underlying problem.  The eventual script I used is different to the one that’s in the old post, so here is the newer one.  Group Policy handles the Services etc, and then this runs in a Computer Startup Script:

#requires -Version 3
# Add missing PSSessionConfigurations (Remoting Endpoints)

Start-Service -Name 'WinRM'

$faulty = $false

if ((Get-PSSessionConfiguration -Name 'Microsoft.PowerShell' -ErrorAction SilentlyContinue) -eq $null) {
    $faulty = $true
}

if ((@(Get-WmiObject -Class Win32_Processor -Property AddressWidth)[0].AddressWidth) -eq 64) {
    if ((Get-PSSessionConfiguration -Name 'Microsoft.PowerShell32' -ErrorAction SilentlyContinue) -eq $null) {
        $faulty = $true
    }
}

if ($PSVersionTable.PSVersion.Major -ge 3) {
    if ((Get-PSSessionConfiguration -Name 'Microsoft.PowerShell.Workflow' -ErrorAction SilentlyContinue) -eq $null) {
        $faulty = $true
    }
}

if ($faulty) {
    try {
        Enable-PSRemoting -Force -SkipNetworkProfileCheck | Out-Null
    } catch {
        try {
            Enable-PSRemoting -Force -SkipNetworkProfileCheck | Out-Null
        } catch {

        }
    }
    Restart-Service -Name 'WinRM'
}

A Computer Startup PowerShell Script does add to boot time but it’s the best solution I could find that worked consistently without doing anything too weird that might cause future problems.  I hope you find it helpful and if anyone ever finds out what the actual cause of the missing endpoints issue is, please post a comment, thanks!

Advertisements