PowerShell script as VisualStudio Post-Build Event loses Logs of Transcript

This topic contains 4 replies, has 2 voices, and was last updated by  studioexpress2013 9 months, 2 weeks ago.

  • Author
    Posts
  • #65578

    studioexpress2013
    Participant

    My Script contains the command Start-Transcript, which is creating a log file.

    If I start the PowerShell.exe and call the Script it is creating the log file correctly.

    If I start the script on the ISE, it gives me an error (This Host doens't support Logs/Records):

    Start-Transcript : Dieser Host unterstützt keine Aufzeichnungen.
    Bei Zeile:12 Zeichen:17
    + Start-Transcript < <<< "C:\transcripts\transcript0.txt" -Path -Force + CategoryInfo : NotImplemented: (:) [Start-Transcript], PSNotSupportedException + FullyQualifiedErrorId : NotSupported,Microsoft.PowerShell.Commands.StartTranscriptCommand But if I run the script as a Post Build Event, it is not logging. **Can anybody explain me why the script is losing the information of the transript if I start itself with Visual Studio (2013 Professional)?**

    powershell.exe -executionpolicy bypass -file "$(SolutionDir)PSTranscriptTest.ps1"

    My PSVersion-Infos:

    4> Name Value
    4> —- —–
    4> CLRVersion 2.0.50727.5485
    4> BuildVersion 6.1.7601.17514
    4> PSVersion 2.0
    4> WSManStackVersion 2.0
    4> PSCompatibleVersions {1.0, 2.0}
    4> SerializationVersion 1.1.0.1
    4> PSRemotingProtocolVersion 2.1

    My Script contains:

    Start-Transcript -Path "C:\transcripts\transcript0.txt" -Force
    Write-Host "Test With Write Host"
    Write-Output "Test With Write Output"
    Verbose "Test With Verbose"
    $PSVersionTable
    Stop-Transcript

    The Output to Screen works. But not to the file.

    The file contains:

    **********************
    Start der Windows PowerShell-Aufzeichnung
    Startzeit: 20170302100746
    Benutzername: User-PC\User
    Computer: USER-PC (Microsoft Windows NT 6.1.7601 Service Pack 1)
    **********************
    **********************
    Ende der Windows PowerShell-Aufzeichnung
    Endzeit: 20170302100746
    **********************

  • #65599

    Don Jones
    Keymaster

    Transcript functionality is a function of the hosting application, not the PowerShell engine. For example, it didn't used to work in the ISE, either. That's the problem – whatever VS is doing to run the script isn't supporting the transcript.

    • #65649

      studioexpress2013
      Participant

      Thank you. How can I know, if a functinality is a function of the hosting application or the PowerShell engine?
      From where can I get this information?

      Can you recommend me an alternative of the start-transcript for simple logging with the PowerShell engine?

  • #65652

    Don Jones
    Keymaster

    You learn those things through experience and by asking questions, as you've done here.

    I would probably write my own logging function.

  • #65679

    studioexpress2013
    Participant

    🙂 Thank you.
    ——————————————————-
    I'll redirect the stream with a parameter to a file.

    powershell.exe -executionpolicy bypass -file "$(SolutionDir)PSTranscriptTest.ps1" > RedirectStream.log

You must be logged in to reply to this topic.