Error running automation policy: "out-lineoutput : The handle is invalid"

Last Modified

Wed Feb 19 21:15 GMT 2020

Description

  • Powershell scripts that work directly on the machine may produce the following output:
' out-lineoutput : The handle is invalid. + CategoryInfo : NotSpecified: (:) [out-lineoutput], IOException + FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.OutLineOutputCommand'

Environment

  • N-able N-central

Solution

  • This error started to appear in Windows 10 builds after 1903 when using the "Run PowerShell Script" object
  • Any code involving creating something on the device needs to be wrapped to a variable.
  • Example:
New-Item -ItemType Directory -Path $Folder
  • Use Instead:
$resultInfo = New-Item -ItemType Directory -Path $Folder -Force
  • Development has also indicated you can downgrade powershell to version 5.1.17763 or upgrade to version 6.0 or 7.0 and this error will not show.