start-transcript causes script to fail in a background job

后端 未结 1 1869
你的背包
你的背包 2020-12-21 08:54

I am creating a powershell script as a background job using start-job which then logs it\'s output using start-transcript. Below is the code of both:

a

相关标签:
1条回答
  • 2020-12-21 09:19

    Apparently Start-Transcript isn't supported in background jobs. If you do a Receive-Job to look at the script output you're likely to see an error like this:

    This host does not support transcription.
        + CategoryInfo          : NotImplemented: (:) [Start-Transcript], PSNotSupportedException
        + FullyQualifiedErrorId : NotSupported,Microsoft.PowerShell.Commands.StartTranscriptCommand
    

    BTW in PowerShell 2.0 I recommend you switch from Set-PSDebug -strict to Set-StrictMode -Version 2.0 - it will catch more potential errors.

    0 讨论(0)
提交回复
热议问题