Skip to content

Add ConvertTo-HumanizedByteSize cmdlet - #21

Open
dfinke with Copilot wants to merge 2 commits into
masterfrom
copilot/add-byte-size-extensions-cmdlet
Open

Add ConvertTo-HumanizedByteSize cmdlet#21
dfinke with Copilot wants to merge 2 commits into
masterfrom
copilot/add-byte-size-extensions-cmdlet

Conversation

CopilotAI commented Dec 31, 2025

Copy link
Copy Markdown

Exposes the Humanizer ByteSizeExtensions.Humanize API as a PowerShell cmdlet.

Changes

  • New cmdlet ConvertTo-HumanizedByteSize in PowerShellHumanizer.psm1

    • Accepts byte values via parameter or pipeline
    • Optional -Format parameter for custom number formatting (e.g., #, 0.00)
    • Automatically selects appropriate units (B, KB, MB, GB, TB)
  • Tests added to PowerShellHumanizer.Tests.ps1

    • Basic conversions, decimal values, format parameter, pipeline support
  • Documentation added to README.md with usage examples

Usage

# Basic usageConvertTo-HumanizedByteSize1048576# 1 MB# Pipeline support1024,2048,3072|ConvertTo-HumanizedByteSize# 1 KB# 2 KB # 3 KB# Custom formattingConvertTo-HumanizedByteSize1536-Format '#'# 2 KB
Original prompt

This section details on the original issue you should resolve

<issue_title>Add [ByteSizeExtensions]::Humanize Cmdlet</issue_title>
<issue_description>Expose this API in a cmdlet.</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: dfinke <67258+dfinke@users.noreply.github.com>
CopilotAI changed the title [WIP] Add ByteSizeExtensions::Humanize cmdletAdd ConvertTo-HumanizedByteSize cmdletDec 31, 2025
CopilotAI requested a review from dfinkeDecember 31, 2025 17:48

@mattcargilemattcargile left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest removing that line.

)

Process {
$byteObject = [Humanizer.ByteSizeExtensions]::Bytes($ByteSize)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not necessary if accepting bytes. [ByteSize] has a constructor to auto convert on the Humanize method.

@dfinke
dfinke marked this pull request as ready for review January 6, 2026 14:01
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add [ByteSizeExtensions]::Humanize Cmdlet

3 participants

@mattcargile@dfinke