-
Notifications
You must be signed in to change notification settings - Fork 7.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ConstrainedLanguage
mode: [pscustomobject]
literals cannot be used, even though the type is white-listed, and an equivalent New-Object
call succeeds
#20767
Comments
@mklement0 Thank you for digging into this. One (side) question, please
What exactly changed in 7.4.0 so that the problem became visible? |
@nightroman, the only thing I'm personally aware of is the presumptive bug in the newly introduced audit mode for the system lockdown feature: |
See also MicrosoftDocs/PowerShell-Docs#6884 & #14071, found via https://stackoverflow.com/questions/64805592/automatically-retrieve-allowed-types-for-constrained-language-mode/64806919#comment114584908_64805592, itself found via https://www.reddit.com/r/PowerShell/comments/10zb95d/pscustomobject_doesnt_work_with_task_scheduler/ @nightroman @mklement0 I think the answers given in the two above issues should address some of the confusion about this voiced here, albeit I haven't had time to read them in detail yet
|
Thank you, @no-identd.
|
Prerequisites
Steps to reproduce
Perhaps I'm missing something, but the fact that hashtable literals alone (without the
[pscustomobject]
"cast") work fine, and that[pscustomobject]
is among the whitelisted types, as well as the fact that the equivalentNew-Object pscustomobject -Property @{ foo = 1 }
does work, leads me to believe that this is a bug (it isn't specific to 7.4.0 - I see it in 7.3.8 too, and even in Windows PowerShell).Expected behavior
A
[pscustomobject]
instance should be constructed and output.Actual behavior
An error occurs (see below).
Error details
Curiously, the error message depends on whether at least one such literal was defined earlier, while the session was still in
FullLanguage
mode:[pscustomobject]
literal was defined before entering constrained mode:Environment data
Visuals
No response
The text was updated successfully, but these errors were encountered: