Benutzer mit den meisten Antworten
PowerShell skript als VisualStudio Post-Build Event verliert Logs von Transcript

Frage
-
Hello,
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 **********************
Antworten
-
Hast Du Dons Antwort auf Powershell.org schon gelesen?
Wenn nicht -> https://powershell.org/forums/topic/powershell-script-as-visualstudio-post-build-event-loses-logs-of-transcript-2/#post-65599
Grüße - Best regards
PS:> (79,108,97,102|%{[char]$_})-join''- Als Antwort vorgeschlagen Denniver ReiningMVP, Moderator Freitag, 3. März 2017 03:43
- Als Antwort markiert Denniver ReiningMVP, Moderator Montag, 6. März 2017 13:30
Alle Antworten
-
Hallo,
man darf hier auch deutsch schreiben, weil es das deutsche PowerShell Forum ist.
Ich denke mal es liegt daran dass dies >>"$(SolutionDir)PSTranscriptTest.ps1"<< nicht sauber aufgelöst wird, versuch es mal mit dem echten Pfad.
PS U:\> $SolutionDir = "C:\Temp\" PS U:\> $SolutionDir C:\Temp\ PS U:\> "$(SolutionDir)PSTranscriptTest.ps1" SolutionDir : Die Benennung "SolutionDir" wurde nicht als Name eines Cmdlet, einer Funktion, einer Skriptdatei oder eines ausführbaren Programms erkannt. Überprüfen Sie die Schreibweise des Namens, oder ob der Pfad korrekt ist (sofern enthalten), und wiederholen Sie den Vorgang. In Zeile:1 Zeichen:4 + "$(SolutionDir)PSTranscriptTest.ps1" + ~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (SolutionDir:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException PSTranscriptTest.ps1 PS U:\> "$($SolutionDir)PSTranscriptTest.ps1" C:\Temp\PSTranscriptTest.ps1
Beste Gruesse
brima- Bearbeitet brima Donnerstag, 2. März 2017 13:11
-
Danke für deine Mithilfe. Es liegt leider nicht an der Auflösung des Pfades. Ich habe den Absoluten Pfad in den Eigenschaften meines VisualStudio Projektes als Post-Build Event eingetragen und das führt zum gleichen Ergebnis:
Die transcript0.txt Datei wird zwar angelegt, aber es wird nichts geloggt:
********************** Start der Windows PowerShell-AufzeichnungStartzeit: 20170302142043 Benutzername: User-PC\User Computer: USER-PC (Microsoft Windows NT 6.1.7601 Service Pack 1) ********************** ********************** Ende der Windows PowerShell-AufzeichnungEndzeit: 20170302142043 **********************
Woran kann es liegen, dass Start-Transcript nichts außer das hier loggt?
-
Hast Du Dons Antwort auf Powershell.org schon gelesen?
Wenn nicht -> https://powershell.org/forums/topic/powershell-script-as-visualstudio-post-build-event-loses-logs-of-transcript-2/#post-65599
Grüße - Best regards
PS:> (79,108,97,102|%{[char]$_})-join''- Als Antwort vorgeschlagen Denniver ReiningMVP, Moderator Freitag, 3. März 2017 03:43
- Als Antwort markiert Denniver ReiningMVP, Moderator Montag, 6. März 2017 13:30