Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Empty folder size value should be set to zero #14449

Copy link
Copy link
@petrasteri

Description

@petrasteri
Issue body actions

Steps to reproduce

We use the following instruction to calculate a folder size

gci c:\my_folder | measure Length -sum

However, if the folder is empty, this instruction returns an error. This happens in PowerShell 5 to PowerShell 7 (Win 10 to Windows Server 2016 to 2019). The error message is:

Measure-Object: Cannot process argument because the value of argument “Property” is not valid. Change the value of the “Property” argument and run the operation again.

Expected behavior

Returns 0. No error. Especially, no red error message on the screen.

Actual behavior

Big RED error message on the screen. Even though 0 is returned, but the error message is annoying.

Environment data

c:\my_folder is an empty folder

My opinion

Measure-Object’s behaviour is correct. So the culprit is the folder object returned by PowerShell. The size property of the folder object should be set to zero by default.

Of course, if other changes in PowerShell's internal working could lead to the disappearance of the error message, I'm happy with that too.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.