i used enum to create a class for my parameter
enum num {
map
}
function test-myinvocation {
param (
[num]$map
)
$pscmdlet
}
i would like to use the input type name ‘num’ in advance
how can i know the type of the parameter which input with variable?
use ($map.gettype()).name to get the type of the input variable
enum num {
map
}
function test-myinvocation {
param (
[num]$map
)
$map.gettype()
}
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True num System.Enum
i try to gettype from $PSBoundParameters with foreach and it rewrite itself
how do you gettype from $PSBoundParameters and fillter it by type name?
enum maplist{
wynncraft
survival_1
survival_2}
[CmdletBinding()]
param (
[Parameter()]
[maplist]
$map
,
# Parameter help description
[Parameter()]
[string]
$type
)
$PSBoundParameters| foreach-object {
$_.values.gettype()
}
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
False False ValueCollection System.Object
system
Closed
4
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.