Steps to reproduce
PowerShell 6Beta2 still has the same gotcha as Windows PowerShell that one needs to manually pass and set the VerbosePreference into scriptblocks, even when using advanced functions. It would be nice if the VerbosePreference of the Invoke-Command Cmdlet would be set automatically in the executed scriptblock.
Invoke-Command -ScriptBlock {Write-Verbose "Hello World"} -Verbose
Invoke-Command -ScriptBlock {[CmdletBinding()]Param() Write-Verbose "Hello World"} -Verbose
Expected behavior
I would expect in both cases that the VerbosePreference gets applied automatically
VERBOSE: Hello World
Actual behavior
No verbose output.
One has to pass and set it manually to get it working:
Invoke-Command -ScriptBlock {[CmdletBinding()]Param($VerbosePreference) Write-Verbose "Hello World"} -Verbose -ArgumentList ('Continue')
Environment data
Name Value
---- -----
PSVersion 6.0.0-beta
PSEdition Core
BuildVersion 3.0.0.0
CLRVersion
GitCommitId v6.0.0-beta.2
OS Microsoft Windows 10.0.15063
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Steps to reproduce
PowerShell 6Beta2 still has the same gotcha as Windows PowerShell that one needs to manually pass and set the VerbosePreference into scriptblocks, even when using advanced functions. It would be nice if the VerbosePreference of the Invoke-Command Cmdlet would be set automatically in the executed scriptblock.
Invoke-Command -ScriptBlock {Write-Verbose "Hello World"} -VerboseInvoke-Command -ScriptBlock {[CmdletBinding()]Param() Write-Verbose "Hello World"} -VerboseExpected behavior
I would expect in both cases that the VerbosePreference gets applied automatically
VERBOSE: Hello WorldActual behavior
No verbose output.
One has to pass and set it manually to get it working:
Invoke-Command -ScriptBlock {[CmdletBinding()]Param($VerbosePreference) Write-Verbose "Hello World"} -Verbose -ArgumentList ('Continue')Environment data