Powershell: ConvertTo-SecureString not working inside background jobs on Linux

Created on 8 Oct 2020  Â·  4Comments  Â·  Source: PowerShell/PowerShell

Using ConvertTo-SecureString inside background jobs works on Windows, but fails on Linux. Tested both inside VS Codespaces and Azure Cloud Shell (repro below is frow the latter).

Steps to reproduce

Start-Job -Name test -ScriptBlock {ConvertTo-SecureString -AsPlainText -Force -String 'test'}

Expected behavior

System.Security.SecureString

Actual behavior

Id     Name            PSJobTypeName   State         HasMoreData     Location             Command
--     ----            -------------   -----         -----------     --------             -------
1      test            BackgroundJob   Failed        False           localhost            ConvertTo-SecureString -…

Environment data

Name                           Value
----                           -----
PSVersion                      7.0.3
PSEdition                      Core
GitCommitId                    7.0.3
OS                             Linux 4.15.0-1096-azure #106~16.04.1-Ubuntu SMP Thu Sep 10 18:51:54 UTC 2020
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Issue-Question

All 4 comments

What error is shown if you retrieve the results from the job?

On Ubuntu 18 I see it failing on PS 7.0.3, but passing on PS 7.1.0-rc.1
@PaulHigin might have more info on this.

PSJobError

SecureString was not implemented on Linux platforms initially because of Windows only dependencies. It was fixed in the 7.0 timeframe but only merged to 7.1 not 7.0.

https://github.com/PowerShell/PowerShell/pull/11185

I see, thanks @PaulHigin

@vexx32 No error or output at all

Was this page helpful?
0 / 5 - 0 ratings