Skip to content

Get-ChildItem should have on option to get size on disk or there should be another command for it #26751

@gamagos

Description

@gamagos

Summary of the new feature / enhancement

I am writing a script that automatically runs some backups in PowerShell 7. And for that I have to know the sizes of the things I want to back up. But I noticed that Get-ChildItem only returns the actual file size and has no way to get the size on the disk that respects the cluster overhead the files can take up, which leads to file size calculations I make to often be smaller than the size on the disk which could prove problematic when evaluating wether another disk I want to copy to or not has enough free space. This is especially true if there are a lot of small files. So as of right now I have to complicatedly load in C# code to make windows API calls to get the cluster size and then make calculatons with that cluster size.
And using fsutil is not really a good option because in my case it seems to require elevated permissions.

Proposed technical implementation details (optional)

Maybe either add a parameter to Get-ChildItem that does this api calling logic itself or add a command that you can pipe results through that gets actual size on disk.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugNeeds-TriageThe issue is new and needs to be triaged by a work group.WG-Enginecore PowerShell engine, interpreter, and runtimeWG-NeedsReviewNeeds a review by the labeled Working Group

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions