mirror of
https://github.com/benclaussen/NetboxPS.git
synced 2025-12-13 09:52:29 +00:00
28 lines
No EOL
659 B
PowerShell
28 lines
No EOL
659 B
PowerShell
|
|
function CreateEnum {
|
|
[CmdletBinding()]
|
|
param
|
|
(
|
|
[Parameter(Mandatory = $true)]
|
|
[string]$EnumName,
|
|
|
|
[Parameter(Mandatory = $true)]
|
|
[pscustomobject]$Values,
|
|
|
|
[switch]$PassThru
|
|
)
|
|
|
|
$definition = @"
|
|
public enum $EnumName
|
|
{`n$(foreach ($value in $values) {
|
|
"`t$($value.label) = $($value.value),`n"
|
|
})
|
|
}
|
|
"@
|
|
if (-not ([System.Management.Automation.PSTypeName]"$EnumName").Type) {
|
|
#Write-Host $definition -ForegroundColor Green
|
|
Add-Type -TypeDefinition $definition -PassThru:$PassThru
|
|
} else {
|
|
Write-Warning "EnumType $EnumName already exists."
|
|
}
|
|
} |