- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
PowerCli/Start-transcript bug
Hi
I have an old script(from 2020, running monthly as a windows schedule task) which seems to be failing recently (less than 6 month ago). Checking the log showed an (almost) empty log file.
In this script I'm using the powershell command start-transcript, to catch output and errors. A lazy mans logging.
But it seems that with one of the recent PowerCli version, PowerCli breaks the Start-transcript command for some reason.
Running the below code as a schedule task (using an AD user, which is local admin)
Start-Transcript -Path "C:\temp\test.log" -Append -Force
import-module VMware.PowerCli -force
Write-host "Hallo World!"
Stop-Transcript
Output
**********************
Windows PowerShell transcript start
Start time: 20220518103905
Username: xxx\xxx
RunAs User: xxx\xxx
Configuration Name:
Machine: xxx (Microsoft Windows NT 10.0.17763.0)
Host Application: powershell.exe -file C:\scripts\repository\Scheduled Scripts\Capcity Report\test.ps1
Process ID: 27140
PSVersion: 5.1.17763.2803
PSEdition: Desktop
PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.17763.2803
BuildVersion: 10.0.17763.2803
CLRVersion: 4.0.30319.42000
WSManStackVersion: 3.0
PSRemotingProtocolVersion: 2.3
SerializationVersion: 1.1.0.1
**********************
Transcript started, output file is C:\temp\test.log
**********************
Windows PowerShell transcript end
End time: 20220518103913
**********************
Note no "Hallo World!"
If I run this code instead the same way as above
import-module VMware.PowerCli -force
Start-Transcript -Path "C:\temp\test.log" -Append -Force
Write-host "Hallo World!"
Stop-Transcript
Output
**********************
Windows PowerShell transcript start
Start time: 20220518104935
Username: xxx\xxx
RunAs User: xxx\xxx
Configuration Name:
Machine: xxx(Microsoft Windows NT 10.0.17763.0)
Host Application: powershell.exe -file C:\scripts\repository\Scheduled Scripts\Capcity Report\test.ps1
Process ID: 20956
PSVersion: 5.1.17763.2803
PSEdition: Desktop
PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.17763.2803
BuildVersion: 10.0.17763.2803
CLRVersion: 4.0.30319.42000
WSManStackVersion: 3.0
PSRemotingProtocolVersion: 2.3
SerializationVersion: 1.1.0.1
**********************
Transcript started, output file is C:\temp\test.log
Hallo World!
**********************
Windows PowerShell transcript end
End time: 20220518104935
**********************
Note "Hallo World!" is now in the output.
So it seems to be a bug in PowerCli, when modules are being loaded. I first noticed this issue when just running a command ( $cred = Get-VICredentialStoreItem -File $TokenFilePath ) and then did the testing with import-module, which seems to produce the same result.
Running this first script manually (in a powershell console) produces this result in the log file
**********************
Windows PowerShell transcript start
Start time: 20220518105520
Username: xxx\xxx
RunAs User: xxx\xxx
Configuration Name:
Machine: xxx(Microsoft Windows NT 10.0.17763.0)
Host Application: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Process ID: 21748
PSVersion: 5.1.17763.2803
PSEdition: Desktop
PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.17763.2803
BuildVersion: 10.0.17763.2803
CLRVersion: 4.0.30319.42000
WSManStackVersion: 3.0
PSRemotingProtocolVersion: 2.3
SerializationVersion: 1.1.0.1
**********************
Transcript started, output file is C:\temp\test.log
PS C:\Users\xxx> import-module VMware.PowerCli -force
**********************
Windows PowerShell transcript end
End time: 20220518105528
**********************
and here is the output in the console
PS C:\Users\xxx> Start-Transcript -Path "C:\temp\test.log" -Append -Force
Transcript started, output file is C:\temp\test.log
PS C:\Users\xxx> import-module VMware.PowerCli -force
Welcome to VMware PowerCLI!
Log in to a vCenter Server or ESX host: Connect-VIServer
To find out what commands are available, type: Get-VICommand
To show searchable help for all PowerCLI commands: Get-PowerCLIHelp
Once you've connected, display all virtual machines: Get-VM
If you need more help, visit the PowerCLI community: Get-PowerCLICommunity
Copyright (C) VMware, Inc. All rights reserved.
PS C:\Users\xxx> Write-host "Hallo World!"
Hallo World!
PS C:\Users\xxx> Stop-Transcript
Stop-Transcript : An error occurred stopping transcription: The host is not currently
transcribing.
At line:1 char:1
+ Stop-Transcript
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Stop-Transcript], PSInvalidOperationExc
eption
+ FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.StopTranscriptC
ommand
PS C:\Users\xxx>
Which seems to agree with me on the fact that something inside PowerCli module is stopping/failing the transcript commandlet. ![]()
Can anyone reproduce this?
PowerCLI Version
----------------
VMware.PowerCLI 12.6.0 build 19610541
---------------
Component Versions
---------------
VMware Common PowerCLI Component 12.6 build 19600917
VMware Cis Core PowerCLI Component PowerCLI Component 12.6 build 19601368
VMware VimAutomation VICore Commands PowerCLI Component PowerCLI Component 12.6 build 19601570