< Back

Import-Enum

Sat Jan 18, 2020 6:50 pm

NAME Import-Enum



SYNOPSIS

Defines an enum.





SYNTAX

Import-Enum [-ModuleBuilder] <ModuleBuilder> [-Name] <String> [-Type] <Type> [-Values] <IDictionary> [-Flags]

[<CommonParameters>]





DESCRIPTION

Defines an enum in the module builder specified.





PARAMETERS

-ModuleBuilder <ModuleBuilder>

The ModuleBuilder object to define the enum in.



Required? true

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Name <String>

The name of the enum to define.



Required? true

Position? 2

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Type <Type>

The enum base type.



Required? true

Position? 3

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Values <IDictionary>

A hashtable of enum key/values to define.



Required? true

Position? 4

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Flags [<SwitchParameter>]

Whether the enum has the [Flags] attribute applied.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>$module_builder = New-DynamicModule -Name PInvokeHelper



Defines

[Flags]

public LogonFlags : uint

{

WithoutProfile = 0,

WithProfile = 1,

NetCredentialsOnly = 2

}



$enum = @{

ModuleBuilder = $module_builder

Name = 'LogonFlags'

Type = ([System.UInt32])

Flags = $true

Values = @{

WithoutProfile = 0

WithProfile = 1

NetCredentialsOnly = 2

}

}

Import-Enum @enum



Defines

public TokenInformationClass : int

{

User = 1,

Groups = 2,

Privileges = 3

}



$enum = @{

ModuleBuilder = $module_builder

Name = 'TokenInformationClass'

Type = ([System.Int32])

Values = @{

User = 1

Groups = 2

Privileges = 3

}

}

Import-Enum @enum











RELATED LINKS