-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module
Description
In normal mode, accessing a property that does not exist returns $null. StrictMode disables this and makes it an exception. That is consistent over several commands - except Get-Member which returns $null. This is surprising, and I expected it should also raise an exception. Should it?
Test cases:
PS C:\> Set-StrictMode -Version 2
PS C:\> $x = Get-Item 'C:\windows'
PS C:\> $x.pretend
The property 'pretend' cannot be found on this object. # PropertyNotFoundStrict
PS C:\> $x | Select-Object -ExpandProperty pretend
Select-Object : Property "pretend" cannot be found # ExpandPropertyNotFound
PS C:\> $x | ForEach-Object -MemberName pretend
ForEach-Object : The input name "pretend" cannot be resolved to a member. # PropertyOrMethodNotFound
PS C:\> $x | Where-Object -Property pretend -eq $null
Where-Object : The input name "pretend" cannot be resolved to a property. # PropertyNotFound
PS C:\> $x.foreach('pretend')
The property 'pretend' cannot be found on this object. # PropertyNotFoundStrict
PS C:\> $x | Get-Member -Name pretend # outputs $nullMetadata
Metadata
Assignees
Labels
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module