PowerTip: Use PowerShell to Reveal the Size of an [int16]

Summary: Use Windows PowerShell to show the minimum value and the maximum value of an [int16].

Hey, Scripting Guy! Question I need to use an [int16], but I am not sure if it is big enough to hold the number I want to use. How can I determine the minimum and the maximum value of an [int16]?

Hey, Scripting Guy! Answer Use the static MinValue and MaxValue properties from the [int16], as shown here.

13:11 C:\> [int16]::MaxValue


13:11 C:\> [int16]::MinValue


Note This technique also works for [int32], [int64], and [double].

Comments (6)

  1. lee says:

    How would one go about using this as a value in a commend? For example,

    Get-Help Out-File -full | out-file .oftest.txt -width [Int32]::MaxValue

    will fail and I'm wondering if there is a way to reference it without creating a variable.



  2. Ed Wilson says:

    @Lee you need to force evaluation of [int32] before you use it. To do this group it, as seen here:

    get-help Out-File | Out-File c:fsooutfile.txt -Width ([int32]::maxvalue)

    PowerShell evaluates stuff in a pair of parentheses before it does the things outside the parentheses.

  3. lee says:


    Thank you! I've been googling like mad to figure that out and kept coming up blank.

  4. Ed Wilson says:

    @Lee you are welcome. Glad to help.

  5. henk says:

    Works also for DateTime:



  6. Ed Wilson says:

    @Henk very cool … I have never done that before. It is a cool trick. Thanks for sharing.