Skip to content

Make Measure-Object ignore missing properties unless running in strict mode #8618

@sdwheeler

Description

@sdwheeler

Prerequisites

  • Write a descriptive title.
  • Search the existing issues.

Summary of the new feature or changed behavior

When using Measure-Object on an empty folder, the "Length" property is invalid. When in StrictMode, an error is thrown when the requested property is not found. The error message is also updated to include the specific property that is not found. The invalid property is simply ignored when not in StrictMode.

PR Context

Unless in StrictMode, missing properties are typically ignored by other commands, so the Measure-Object command should do the same. This pull-request updates the Measure-Object command to only throw a property not found error when in StrictMode and ignores the property not found when not in StrictMode. This functionality is now consistent with other PowerShell commands.

List of articles that need to be updated

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/measure-object?view=powershell-7.3

Link to related PR in PowerShell/PowerShell repo

PowerShell/PowerShell#16589

Link to related Issues in PowerShell/PowerShell repo

PowerShell/PowerShell#14449

Metadata

Metadata

Labels

area-utilityArea - Microsoft.PowerShell.Utility module

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions