-
Notifications
You must be signed in to change notification settings - Fork 225
/
Test-IsNumericType.ps1
50 lines (42 loc) · 1.13 KB
/
Test-IsNumericType.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<#
.SYNOPSIS
Returns wether the specified object is of a numeric type.
.DESCRIPTION
Returns wether the specified object is of a numeric type.
.PARAMETER Object
The object to test if it is a numeric type.
.EXAMPLE
Test-IsNumericType -Object ([System.UInt32] 1)
Returns $true since the object passed is of a numeric type.
.OUTPUTS
[System.Boolean]
#>
function Test-IsNumericType
{
[CmdletBinding()]
[OutputType([System.Boolean])]
param
(
[Parameter(ValueFromPipeline = $true)]
[System.Object]
$Object
)
$isNumeric = $false
if (
$Object -is [System.Byte] -or
$Object -is [System.Int16] -or
$Object -is [System.Int32] -or
$Object -is [System.Int64] -or
$Object -is [System.SByte] -or
$Object -is [System.UInt16] -or
$Object -is [System.UInt32] -or
$Object -is [System.UInt64] -or
$Object -is [System.Decimal] -or
$Object -is [System.Double] -or
$Object -is [System.Single]
)
{
$isNumeric = $true
}
return $isNumeric
}