Long running (>8hours) process via winRM is terminated at 8 hours.

Phil Yardley 1 Reputation point
2021-11-01T16:58:32.063+00:00

Is there a way to change the MaxShellRuntime setting in WinRM 2 & 3?

according to the docs, this is now a read only value since WinRM 2

https://learn.microsoft.com/en-us/windows/win32/winrm/installation-and-configuration-for-windows-remote-management#maxshellruntime

but we have many long running data import processes that we need to trigger remotely and these can easily take longer than 8 hours.

on our legacy servers (despite running WinRM 2 or 3), this doesn't seem to be an issue - I suspect these were originally WinRM 1 and updates have not overwritten the extended values.

I'm guessing (hoping) that there might be a registry hack that will allow us to change the value ?

these legacy on-prem servers are being migrated to the cloud and as each new machine is created, we are stuck with the 8hour time out.

any pointers would be appreciated.

Phil

Windows for business | Windows Server | User experience | Other
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. MotoX80 36,401 Reputation points
    2021-11-01T23:05:37.88+00:00

    Not sure if this will help you or not, but what do you get when you run this command?

    winrm get winrm/config/Winrs
    

    On Win10 I see "MaxShellRunTime = 2147483647". The site you referred to says the default is 28800000 which is 8 hours. Does your system show 28800000?

    I found registry entries at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WSMAN\WinRS but MaxShellRunTime is not there.

    I also tried to update the value, but winrm complained that it was a deprecated setting. You could try that.

    winrm set winrm/config/WinRs @{MaxShellRunTime="2147483647"}
    

  2. MotoX80 36,401 Reputation points
    2021-11-03T12:02:12.253+00:00

    From my Win10 Home laptop I was able to run a 9 hour Invoke-Command against my Win10 Pro VM. Try using a PSSession-Option.

     $User = ".\admin"
     $PWord = ConvertTo-SecureString -String "admin" -AsPlainText -Force
     $Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $PWord
     $sec = (60 * 60) * 9
    
     $opts = New-PSSessionOption -IdleTimeout 99999 -OperationTimeout 99999 
    
     Get-Date
     Invoke-Command -ComputerName "test10" -credential $Credential -ScriptBlock {start-sleep -Seconds $using:sec} -SessionOption $opts
     Get-Date
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.