-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGet-Type.ps1
More file actions
44 lines (38 loc) · 978 Bytes
/
Get-Type.ps1
File metadata and controls
44 lines (38 loc) · 978 Bytes
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
<#
.SYNOPSIS
Get the valid type from the TypeName string.
.DESCRIPTION
Get the valid type from the TypeName string.
.PARAMETER Type
Optional. TypeName string name.
.OUTPUTS
Return valid Type of the any object or properties
.EXAMPLE
Get-Type -Type 'System.Byte'
[System.Type]::GetType("$(Get-Type 'System.String')")
#>
function Get-Type {
param($Type)
$TypeList = @(
'System.Boolean',
'System.Byte[]',
'System.Byte',
'System.Char',
'System.Datetime',
'System.Decimal',
'System.Double',
'System.Guid',
'System.Int16',
'System.Int32',
'System.Int64',
'System.Single',
'System.UInt16',
'System.UInt32',
'System.UInt64')
if ( $TypeList -contains $Type ) {
Write-Output "$Type"
}
else {
Write-Output 'System.String'
}
}