Start-Transcript: This host does not support transcription

前端 未结 7 2033
难免孤独
难免孤独 2021-02-05 04:50

I want to start a transcript on a Windows Server 2008 R2

Start-Transcript -path C:\\Temp\\test.txt
\"Hello!\"
Stop-Transcript

But PowerShe

相关标签:
7条回答
  • 2021-02-05 05:42

    Following the tip from @richard here I created a snippet that allows usage of Transaction logs where I need them (scheduled tasks), so I ended having in Windows 2008R2 the following code that can be run from powershell ISE or as a standalone script.

    • When run in ISE, the log information will be printed on screen
    • When run as a script, the log information will be saved to a file
    if ($Host.Name -eq "Windows PowerShell ISE Host") {
        $ISE=$true
    } else {
        $ISE=$false
    }
    
    
    if (-Not $ISE) {
        $Date = Get-Date -f HHmmss_ddyyyy
        Start-Transcript -Path "C:\Temp\$Date.log"
    }
    
    //////////
    code here ...
    //////////
    
    if (-Not $ISE) {
        Stop-Transcript
    }
    
    0 讨论(0)
提交回复
热议问题