dwalker3rd / Overwatch

GNU General Public License v3.0
3 stars 0 forks source link

in config-ps-remoting.ps1, if enable-psremoting fails to restart, catch and force stop/reenable #47

Closed dwalker3rd closed 10 months ago

dwalker3rd commented 10 months ago
    $ignoreOutput = Enable-PSRemoting -skipnetworkprofilecheck -force
    $winRmService = Get-Service+ WinRM
    $winRmRuntime = (Get-Date -AsUTC) - $winRmService.CreationDate
    if ($winRmRuntime -gt (New-TimeSpan -Seconds 15)) {
        Stop-Service WinRM -Force
        $ignoreOutput = Enable-PSRemoting -skipnetworkprofilecheck -force
        $winRmService = Get-Service+ WinRM
        $winRmRuntime = (Get-Date -AsUTC) - $winRmService.CreationDate
    }
    if ($winRmService.State -ne "Running") {
        Start-Service WinRM
    }