February 2019
Intermediate to advanced
626 pages
15h 51m
English
Considering that enumerations are lists of names, each assigned a numeric value. A pair of enumerations to convert between two lists of names, linked only by a common value.
The following example defines two enumerations. The first is a list of values the end user will see, the second holds the internal name required by the code. This simulates, in part, the type of aliasing performed by the wmic command:
enum AliasName { OS Process}enum ClassName { Win32_OperatingSystem Win32_Process}
A function might use the AliasName enumeration, as shown here:
function Get-CimAliasInstance { [CmdletBinding()] param ( [Parameter(Mandatory, Position = 1)] [AliasName]$AliasName ) Get-CimInstance -ClassName ([ClassName]$AliasName) ...Read now
Unlock full access