Skip to content

Test IsNumericType

dscbot edited this page Feb 13, 2024 · 2 revisions

Test-IsNumericType

SYNOPSIS

Returns whether the specified object is of a numeric type.

SYNTAX

Test-IsNumericType [[-Object] <Object>] [<CommonParameters>]

DESCRIPTION

Returns whether the specified object is of a numeric type:

  • [System.Byte]
  • [System.Int16]
  • [System.Int32]
  • [System.Int64]
  • [System.SByte]
  • [System.UInt16]
  • [System.UInt32]
  • [System.UInt64]
  • [System.Decimal]
  • [System.Double]
  • [System.Single]

EXAMPLES

EXAMPLE 1

Test-IsNumericType -Object ([System.UInt32] 1)

Returns $true since the object passed is of a numeric type.

EXAMPLE 2

([System.String] 'a') | Test-IsNumericType

Returns $false since the value is not a numeric type.

EXAMPLE 3

('a', 2, 'b') | Test-IsNumericType

Returns $true since one of the values in the array is of a numeric type.

PARAMETERS

-Object

The object to test if it is a numeric type.

Type: Object
Parameter Sets: (All)
Aliases:

Required: False
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

[System.Boolean]

NOTES

When passing in an array of values from the pipeline, the command will return $true if any of the values in the array is numeric.

RELATED LINKS

Clone this wiki locally