Powershell: ?. operator fails on Linux 7.0.3 but works on Windows 7.0.3

Created on 27 Aug 2020  路  5Comments  路  Source: PowerShell/PowerShell

With 7.0.3 the ?. operator works on Windows but not Linux.

Steps to reproduce

$test = @{ field = 'value' }
${test}?.field

Expected behavior

value

Actual behavior

ParserError: You must provide a value expression following the '?' operator.

Environment data

Name                           Value
----                           -----
PSVersion                      7.0.3
PSEdition                      Core
GitCommitId                    7.0.3
OS                             Linux 4.4.0-18362-Microsoft #836-Microsoft Mon May 05 16:04:00 PST 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

Most helpful comment

You need to enable this experimental feature in 7.0.3:

Enable-ExperimentalFeature PSNullConditionalOperators

All 5 comments

You need to enable this experimental feature in 7.0.3:

Enable-ExperimentalFeature PSNullConditionalOperators

You need to enable this experimental feature in 7.0.3:

Enable-ExperimentalFeature PSNullConditionalOperators

Hmm... I didn't think I had enabled any of them but that one option is turned on so I guess I did. Sorry for not recognizing that.

No worries. :-)

Just an FYI

This experimental feature seems already included in 7.1.0-Preview.6.

:)

User error. Didn't realize I'd at some point enabled this experimental feature on my Windows machine - I assume I did it though if so, no recollection and the others weren't enabled.

In any event, easy remedy to enable on Linux.

Was this page helpful?
0 / 5 - 0 ratings