Win32_DirectorySpecification

The Win32_DirectorySpecification class represents the directory layout for the product. Each instance of the class represents a directory in both the source image and the destination image.Director...

The Win32_DirectorySpecification class represents the directory layout for the product. Each instance of the class represents a directory in both the source image and the destination image. Directory resolution is performed as follows:

Methods

Win32_DirectorySpecification has no methods.

Properties

Win32_DirectorySpecification returns 13 properties:

'Caption','CheckID','CheckMode','DefaultDir','Description','Directory','DirectoryPath',
'DirectoryType','Name','SoftwareElementID','SoftwareElementState','TargetOperatingSystem','Version'

Unless explicitly marked as writeable, all properties are read-only. Read all properties for all instances:

Get-CimInstance -ClassName Win32_DirectorySpecification -Property *

Most WMI classes return one or more instances.

When Get-CimInstance returns no result, then apparently no instances of class Win32_DirectorySpecification exist. This is normal behavior.

Either the class is not implemented on your system (may be deprecated or due to missing drivers, i.e. CIM_VideoControllerResolution), or there are simply no physical representations of this class currently available (i.e. Win32_TapeDrive).

Caption

STRING

Short description of the object.

Get-CimInstance -ClassName Win32_DirectorySpecification | Select-Object -Property CheckID, Caption

CheckID

KEY PROPERTY STRING

Identifier used in conjunction with other keys to uniquely identify the check.

Get-CimInstance -ClassName Win32_DirectorySpecification | Select-Object -Property CheckID

CheckMode

BOOLEAN

Condition is expected to exist or not exist in the environment. When TRUE, the condition is expected to exist (a file is expected to be on a system) so the Invoke() method is expected to return TRUE.

Get-CimInstance -ClassName Win32_DirectorySpecification | Select-Object -Property CheckID, CheckMode

DefaultDir

STRING

Get-CimInstance -ClassName Win32_DirectorySpecification | Select-Object -Property CheckID, DefaultDir

Description

STRING

Description of the objects.

Get-CimInstance -ClassName Win32_DirectorySpecification | Select-Object -Property CheckID, Description

Directory

STRING

Get-CimInstance -ClassName Win32_DirectorySpecification | Select-Object -Property CheckID, Directory

DirectoryPath

STRING

Name of a directory. The value supplied by an application provider is actually a default or recommended path name and can be changed for a particular environment.

Get-CimInstance -ClassName Win32_DirectorySpecification | Select-Object -Property CheckID, DirectoryPath

DirectoryType

UINT16

Type of directory being described.

DirectoryType returns a numeric value. To translate it into a meaningful text, use any of the following approaches:

Use a PowerShell Hashtable
$DirectoryType_map = @{
Product log directory = '1'
Shared base directory = '2'
Shared executable directory = '3'
Shared library directory = '4'
Shared include directory = '5'
System base directory = '6'
System executable directory = '7'
System library directory = '8'
System configuration directory = '9'
System include directory = '10'
System log directory = '11'
  Other = '12'
}
Use a switch statement
switch([int]$value)
{
  Product log directory {'1'}
  Shared base directory {'2'}
  Shared executable directory {'3'}
  Shared library directory {'4'}
  Shared include directory {'5'}
  System base directory {'6'}
  System executable directory {'7'}
  System library directory {'8'}
  System configuration directory {'9'}
  System include directory {'10'}
  System log directory {'11'}
  Other      {'12'}
  default    {"$value"}
}
Use Enum structure
Enum EnumDirectoryType
{
  _1    = Product log directory
  _2    = Shared base directory
  _3    = Shared executable directory
  _4    = Shared library directory
  _5    = Shared include directory
  _6    = System base directory
  _7    = System executable directory
  _8    = System library directory
  _9    = System configuration directory
  _10   = System include directory
  _11   = System log directory
  _12   = Other
}

Examples

Use $DirectoryType_map in a calculated property for Select-Object
<# 
  this example uses a hashtable to translate raw numeric values for 
  property "DirectoryType" to friendly text

  Note: to use other properties than "DirectoryType", look up the appropriate 
  translation hashtable for the property you would like to use instead.
#>

#region define hashtable to translate raw values to friendly text

# Please note: this hashtable is specific for property "DirectoryType" 
# to translate other properties, use their translation table instead
$DirectoryType_map = @{
Product log directory = '1'
Shared base directory = '2'
Shared executable directory = '3'
Shared library directory = '4'
Shared include directory = '5'
System base directory = '6'
System executable directory = '7'
System library directory = '8'
System configuration directory = '9'
System include directory = '10'
System log directory = '11'
  Other = '12'
}

#endregion define hashtable

#region define calculated property (to be used with Select-Object)

<#
  a calculated property is defined by a hashtable with keys "Name" and "Expression"
  "Name" defines the name of the property (in this example, it is "DirectoryType", but you can rename it to anything else)
  "Expression" defines a scriptblock that calculates the content of this property
  in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
  value to its friendly text counterpart:
#>
 
$DirectoryType = @{
  Name = 'DirectoryType'
  Expression = {
    # property is an array, so process all values
    $value = $_.DirectoryType
    $DirectoryType_map[[int]$value]
  }  
}
#endregion define calculated property

# retrieve the instances, and output the properties "Caption" and "DirectoryType". The latter
# is defined by the hashtable in $DirectoryType: 
Get-CimInstance -Class Win32_DirectorySpecification | Select-Object -Property Caption, $DirectoryType

# ...or dump content of property DirectoryType:
$friendlyValues = Get-CimInstance -Class Win32_DirectorySpecification | 
    Select-Object -Property $DirectoryType |
    Select-Object -ExpandProperty DirectoryType

# output values
$friendlyValues

# output values as comma separated list
$friendlyValues -join ', '

# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $DirectoryType_map to directly translate raw values from an instance
<# 
  this example uses a hashtable to manually translate raw numeric values 
  for property "Win32_DirectorySpecification" to friendly text. This approach is ideal when
  there is just one instance to work with.

  Note: to use other properties than "Win32_DirectorySpecification", look up the appropriate 
  translation hashtable for the property you would like to use instead.
#>

#region define hashtable to translate raw values to friendly text

# Please note: this hashtable is specific for property "Win32_DirectorySpecification" 
# to translate other properties, use their translation table instead
$DirectoryType_map = @{
Product log directory = '1'
Shared base directory = '2'
Shared executable directory = '3'
Shared library directory = '4'
Shared include directory = '5'
System base directory = '6'
System executable directory = '7'
System library directory = '8'
System configuration directory = '9'
System include directory = '10'
System log directory = '11'
  Other = '12'
}

#endregion define hashtable

# get one instance:
$instance = Get-CimInstance -Class Win32_DirectorySpecification | Select-Object -First 1

<#
  IMPORTANT: this example processes only one instance to illustrate
  the number-to-text translation. To process all instances, replace
  "Select-Object -First 1" with a "Foreach-Object" loop, and use
  the iterator variable $_ instead of $instance
#>

# query the property
$rawValue = $instance.DirectoryType  

# translate raw value to friendly text:
$friendlyName = $DirectoryType_map[[int]$rawValue]

# output value
$friendlyName
Use a switch statement inside a calculated property for Select-Object
<# 
  this example uses a switch clause to translate raw numeric 
  values for property "DirectoryType" to friendly text. The switch
  clause is embedded into a calculated property so there is
  no need to refer to external variables for translation.

  Note: to use other properties than "DirectoryType", look up the appropriate 
  translation switch clause for the property you would like to use instead.
#>

#region define calculated property (to be used with Select-Object)

<#
  a calculated property is defined by a hashtable with keys "Name" and "Expression"
  "Name" defines the name of the property (in this example, it is "DirectoryType", but you can rename it to anything else)
  "Expression" defines a scriptblock that calculates the content of this property
  in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
  value to its friendly text counterpart:
#>
 
$DirectoryType = @{
  Name = 'DirectoryType'
  Expression = {
    # property is an array, so process all values
    $value = $_.DirectoryType
    
    switch([int]$value)
      {
        Product log directory {'1'}
        Shared base directory {'2'}
        Shared executable directory {'3'}
        Shared library directory {'4'}
        Shared include directory {'5'}
        System base directory {'6'}
        System executable directory {'7'}
        System library directory {'8'}
        System configuration directory {'9'}
        System include directory {'10'}
        System log directory {'11'}
        Other      {'12'}
        default    {"$value"}
      }
      
  }  
}
#endregion define calculated property

# retrieve all instances...
Get-CimInstance -ClassName Win32_DirectorySpecification | 
  # ...and output properties "Caption" and "DirectoryType". The latter is defined
  # by the hashtable in $DirectoryType:
  Select-Object -Property Caption, $DirectoryType
Use the Enum from above to auto-translate the code values
<# 
  this example translates raw values by means of type conversion
  the friendly names are defined as enumeration using the
  keyword "enum" (PowerShell 5 or better)
  
  The raw value(s) are translated to friendly text by 
  simply converting them into the enum type.
  
  Note: to use other properties than "Win32_DirectorySpecification", look up the appropriate 
  enum definition for the property you would like to use instead.
#>


#region define enum with value-to-text translation:
Enum EnumDirectoryType
{
  _1    = Product log directory
  _2    = Shared base directory
  _3    = Shared executable directory
  _4    = Shared library directory
  _5    = Shared include directory
  _6    = System base directory
  _7    = System executable directory
  _8    = System library directory
  _9    = System configuration directory
  _10   = System include directory
  _11   = System log directory
  _12   = Other
}

#endregion define enum

# get one instance:
$instance = Get-CimInstance -Class Win32_DirectorySpecification | Select-Object -First 1

<#
  IMPORTANT: this example processes only one instance to focus on
  the number-to-text type conversion. 
  
  To process all instances, replace   "Select-Object -First 1" 
  with a "Foreach-Object" loop, and use the iterator variable 
  $_ instead of $instance
#>

# query the property:
$rawValue = $instance.DirectoryType

#region using strict type conversion

<#
  Note: strict type conversion fails if the raw value is 
  not defined by the enum. So if the list of allowable values
  was extended and the enum does not match the value,
  an exception is thrown
#>

# convert the property to the enum **DirectoryType** 
[EnumDirectoryType]$rawValue 

# get a comma-separated string:
[EnumDirectoryType]$rawValue -join ',' 
#endregion

#region using operator "-as"

<#
  Note: the operator "-as" accepts values not defined
  by the enum and returns $null instead of throwing
  an exception
#>

$rawValue -as [EnumDirectoryType]
#endregion

Enums must cover all possible values. If DirectoryType returns a value that is not defined in the enum, an exception occurs. The exception reports the value that was missing in the enum. To fix, add the missing value to the enum.

Name

STRING

Name used to identify this software element.

Get-CimInstance -ClassName Win32_DirectorySpecification | Select-Object -Property CheckID, Name

SoftwareElementID

STRING

Identifier for this software element. Designed to be used in conjunction with other keys to create a unique representation of this CIM_SoftwareElement instance.

Get-CimInstance -ClassName Win32_DirectorySpecification | Select-Object -Property CheckID, SoftwareElementID

SoftwareElementState

UINT16

State of a software element.

SoftwareElementState returns a numeric value. To translate it into a meaningful text, use any of the following approaches:

Use a PowerShell Hashtable
$SoftwareElementState_map = @{
Disabled = '1'
Installable = '2'
Executable = '3'
Running = '4'
}
Use a switch statement
switch([int]$value)
{
  Disabled   {'1'}
  Installable {'2'}
  Executable {'3'}
  Running    {'4'}
  default    {"$value"}
}
Use Enum structure
Enum EnumSoftwareElementState
{
  _1   = Disabled
  _2   = Installable
  _3   = Executable
  _4   = Running
}

Examples

Use $SoftwareElementState_map in a calculated property for Select-Object
<# 
  this example uses a hashtable to translate raw numeric values for 
  property "SoftwareElementState" to friendly text

  Note: to use other properties than "SoftwareElementState", look up the appropriate 
  translation hashtable for the property you would like to use instead.
#>

#region define hashtable to translate raw values to friendly text

# Please note: this hashtable is specific for property "SoftwareElementState" 
# to translate other properties, use their translation table instead
$SoftwareElementState_map = @{
Disabled = '1'
Installable = '2'
Executable = '3'
Running = '4'
}

#endregion define hashtable

#region define calculated property (to be used with Select-Object)

<#
  a calculated property is defined by a hashtable with keys "Name" and "Expression"
  "Name" defines the name of the property (in this example, it is "SoftwareElementState", but you can rename it to anything else)
  "Expression" defines a scriptblock that calculates the content of this property
  in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
  value to its friendly text counterpart:
#>
 
$SoftwareElementState = @{
  Name = 'SoftwareElementState'
  Expression = {
    # property is an array, so process all values
    $value = $_.SoftwareElementState
    $SoftwareElementState_map[[int]$value]
  }  
}
#endregion define calculated property

# retrieve the instances, and output the properties "Caption" and "SoftwareElementState". The latter
# is defined by the hashtable in $SoftwareElementState: 
Get-CimInstance -Class Win32_DirectorySpecification | Select-Object -Property Caption, $SoftwareElementState

# ...or dump content of property SoftwareElementState:
$friendlyValues = Get-CimInstance -Class Win32_DirectorySpecification | 
    Select-Object -Property $SoftwareElementState |
    Select-Object -ExpandProperty SoftwareElementState

# output values
$friendlyValues

# output values as comma separated list
$friendlyValues -join ', '

# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $SoftwareElementState_map to directly translate raw values from an instance
<# 
  this example uses a hashtable to manually translate raw numeric values 
  for property "Win32_DirectorySpecification" to friendly text. This approach is ideal when
  there is just one instance to work with.

  Note: to use other properties than "Win32_DirectorySpecification", look up the appropriate 
  translation hashtable for the property you would like to use instead.
#>

#region define hashtable to translate raw values to friendly text

# Please note: this hashtable is specific for property "Win32_DirectorySpecification" 
# to translate other properties, use their translation table instead
$SoftwareElementState_map = @{
Disabled = '1'
Installable = '2'
Executable = '3'
Running = '4'
}

#endregion define hashtable

# get one instance:
$instance = Get-CimInstance -Class Win32_DirectorySpecification | Select-Object -First 1

<#
  IMPORTANT: this example processes only one instance to illustrate
  the number-to-text translation. To process all instances, replace
  "Select-Object -First 1" with a "Foreach-Object" loop, and use
  the iterator variable $_ instead of $instance
#>

# query the property
$rawValue = $instance.SoftwareElementState  

# translate raw value to friendly text:
$friendlyName = $SoftwareElementState_map[[int]$rawValue]

# output value
$friendlyName
Use a switch statement inside a calculated property for Select-Object
<# 
  this example uses a switch clause to translate raw numeric 
  values for property "SoftwareElementState" to friendly text. The switch
  clause is embedded into a calculated property so there is
  no need to refer to external variables for translation.

  Note: to use other properties than "SoftwareElementState", look up the appropriate 
  translation switch clause for the property you would like to use instead.
#>

#region define calculated property (to be used with Select-Object)

<#
  a calculated property is defined by a hashtable with keys "Name" and "Expression"
  "Name" defines the name of the property (in this example, it is "SoftwareElementState", but you can rename it to anything else)
  "Expression" defines a scriptblock that calculates the content of this property
  in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
  value to its friendly text counterpart:
#>
 
$SoftwareElementState = @{
  Name = 'SoftwareElementState'
  Expression = {
    # property is an array, so process all values
    $value = $_.SoftwareElementState
    
    switch([int]$value)
      {
        Disabled   {'1'}
        Installable {'2'}
        Executable {'3'}
        Running    {'4'}
        default    {"$value"}
      }
      
  }  
}
#endregion define calculated property

# retrieve all instances...
Get-CimInstance -ClassName Win32_DirectorySpecification | 
  # ...and output properties "Caption" and "SoftwareElementState". The latter is defined
  # by the hashtable in $SoftwareElementState:
  Select-Object -Property Caption, $SoftwareElementState
Use the Enum from above to auto-translate the code values
<# 
  this example translates raw values by means of type conversion
  the friendly names are defined as enumeration using the
  keyword "enum" (PowerShell 5 or better)
  
  The raw value(s) are translated to friendly text by 
  simply converting them into the enum type.
  
  Note: to use other properties than "Win32_DirectorySpecification", look up the appropriate 
  enum definition for the property you would like to use instead.
#>


#region define enum with value-to-text translation:
Enum EnumSoftwareElementState
{
  _1   = Disabled
  _2   = Installable
  _3   = Executable
  _4   = Running
}

#endregion define enum

# get one instance:
$instance = Get-CimInstance -Class Win32_DirectorySpecification | Select-Object -First 1

<#
  IMPORTANT: this example processes only one instance to focus on
  the number-to-text type conversion. 
  
  To process all instances, replace   "Select-Object -First 1" 
  with a "Foreach-Object" loop, and use the iterator variable 
  $_ instead of $instance
#>

# query the property:
$rawValue = $instance.SoftwareElementState

#region using strict type conversion

<#
  Note: strict type conversion fails if the raw value is 
  not defined by the enum. So if the list of allowable values
  was extended and the enum does not match the value,
  an exception is thrown
#>

# convert the property to the enum **SoftwareElementState** 
[EnumSoftwareElementState]$rawValue 

# get a comma-separated string:
[EnumSoftwareElementState]$rawValue -join ',' 
#endregion

#region using operator "-as"

<#
  Note: the operator "-as" accepts values not defined
  by the enum and returns $null instead of throwing
  an exception
#>

$rawValue -as [EnumSoftwareElementState]
#endregion

Enums must cover all possible values. If SoftwareElementState returns a value that is not defined in the enum, an exception occurs. The exception reports the value that was missing in the enum. To fix, add the missing value to the enum.

TargetOperatingSystem

UINT16

Target operating system of the owning software element. The possible values for this property are as follows.

TargetOperatingSystem returns a numeric value. To translate it into a meaningful text, use any of the following approaches:

Use a PowerShell Hashtable
$TargetOperatingSystem_map = @{
Unknown = '0'
  Other = '1'
  MACOS = '2'
ATTUNIX = '3'
   DGUX = '4'
  DECNT = '5'
Digital UNIX = '6'
OpenVMS = '7'
   HPUX = '8'
    AIX = '9'
    MVS = '10'
  OS400 = '11'
   OS/2 = '12'
 JavaVM = '13'
  MSDOS = '14'
  WIN3x = '15'
  WIN95 = '16'
  WIN98 = '17'
  WINNT = '18'
  WINCE = '19'
NCR3000 = '20'
NetWare = '21'
    OSF = '22'
  DC/OS = '23'
Reliant UNIX = '24'
SCO UnixWare = '25'
SCO OpenServer = '26'
Sequent = '27'
   IRIX = '28'
Solaris = '29'
  SunOS = '30'
  U6000 = '31'
ASERIES = '32'
TandemNSK = '33'
TandemNT = '34'
 BS2000 = '35'
  LINUX = '36'
   Lynx = '37'
  XENIX = '38'
 VM/ESA = '39'
Interactive UNIX = '40'
BSDUNIX = '41'
FreeBSD = '42'
 NetBSD = '43'
GNU Hurd = '44'
    OS9 = '45'
MACH Kernel = '46'
Inferno = '47'
    QNX = '48'
   EPOC = '49'
IxWorks = '50'
VxWorks = '51'
   MiNT = '52'
   BeOS = '53'
 HP MPE = '54'
NextStep = '55'
PalmPilot = '56'
Rhapsody = '57'
}
Use a switch statement
switch([int]$value)
{
  Unknown    {'0'}
  Other      {'1'}
  MACOS      {'2'}
  ATTUNIX    {'3'}
  DGUX       {'4'}
  DECNT      {'5'}
  Digital UNIX {'6'}
  OpenVMS    {'7'}
  HPUX       {'8'}
  AIX        {'9'}
  MVS        {'10'}
  OS400      {'11'}
  OS/2       {'12'}
  JavaVM     {'13'}
  MSDOS      {'14'}
  WIN3x      {'15'}
  WIN95      {'16'}
  WIN98      {'17'}
  WINNT      {'18'}
  WINCE      {'19'}
  NCR3000    {'20'}
  NetWare    {'21'}
  OSF        {'22'}
  DC/OS      {'23'}
  Reliant UNIX {'24'}
  SCO UnixWare {'25'}
  SCO OpenServer {'26'}
  Sequent    {'27'}
  IRIX       {'28'}
  Solaris    {'29'}
  SunOS      {'30'}
  U6000      {'31'}
  ASERIES    {'32'}
  TandemNSK  {'33'}
  TandemNT   {'34'}
  BS2000     {'35'}
  LINUX      {'36'}
  Lynx       {'37'}
  XENIX      {'38'}
  VM/ESA     {'39'}
  Interactive UNIX {'40'}
  BSDUNIX    {'41'}
  FreeBSD    {'42'}
  NetBSD     {'43'}
  GNU Hurd   {'44'}
  OS9        {'45'}
  MACH Kernel {'46'}
  Inferno    {'47'}
  QNX        {'48'}
  EPOC       {'49'}
  IxWorks    {'50'}
  VxWorks    {'51'}
  MiNT       {'52'}
  BeOS       {'53'}
  HP MPE     {'54'}
  NextStep   {'55'}
  PalmPilot  {'56'}
  Rhapsody   {'57'}
  default    {"$value"}
}
Use Enum structure
Enum EnumTargetOperatingSystem
{
  _0    = Unknown
  _1    = Other
  _2    = MACOS
  _3    = ATTUNIX
  _4    = DGUX
  _5    = DECNT
  _6    = Digital UNIX
  _7    = OpenVMS
  _8    = HPUX
  _9    = AIX
  _10   = MVS
  _11   = OS400
  _12   = OS/2
  _13   = JavaVM
  _14   = MSDOS
  _15   = WIN3x
  _16   = WIN95
  _17   = WIN98
  _18   = WINNT
  _19   = WINCE
  _20   = NCR3000
  _21   = NetWare
  _22   = OSF
  _23   = DC/OS
  _24   = Reliant UNIX
  _25   = SCO UnixWare
  _26   = SCO OpenServer
  _27   = Sequent
  _28   = IRIX
  _29   = Solaris
  _30   = SunOS
  _31   = U6000
  _32   = ASERIES
  _33   = TandemNSK
  _34   = TandemNT
  _35   = BS2000
  _36   = LINUX
  _37   = Lynx
  _38   = XENIX
  _39   = VM/ESA
  _40   = Interactive UNIX
  _41   = BSDUNIX
  _42   = FreeBSD
  _43   = NetBSD
  _44   = GNU Hurd
  _45   = OS9
  _46   = MACH Kernel
  _47   = Inferno
  _48   = QNX
  _49   = EPOC
  _50   = IxWorks
  _51   = VxWorks
  _52   = MiNT
  _53   = BeOS
  _54   = HP MPE
  _55   = NextStep
  _56   = PalmPilot
  _57   = Rhapsody
}

Examples

Use $TargetOperatingSystem_map in a calculated property for Select-Object
<# 
  this example uses a hashtable to translate raw numeric values for 
  property "TargetOperatingSystem" to friendly text

  Note: to use other properties than "TargetOperatingSystem", look up the appropriate 
  translation hashtable for the property you would like to use instead.
#>

#region define hashtable to translate raw values to friendly text

# Please note: this hashtable is specific for property "TargetOperatingSystem" 
# to translate other properties, use their translation table instead
$TargetOperatingSystem_map = @{
Unknown = '0'
  Other = '1'
  MACOS = '2'
ATTUNIX = '3'
   DGUX = '4'
  DECNT = '5'
Digital UNIX = '6'
OpenVMS = '7'
   HPUX = '8'
    AIX = '9'
    MVS = '10'
  OS400 = '11'
   OS/2 = '12'
 JavaVM = '13'
  MSDOS = '14'
  WIN3x = '15'
  WIN95 = '16'
  WIN98 = '17'
  WINNT = '18'
  WINCE = '19'
NCR3000 = '20'
NetWare = '21'
    OSF = '22'
  DC/OS = '23'
Reliant UNIX = '24'
SCO UnixWare = '25'
SCO OpenServer = '26'
Sequent = '27'
   IRIX = '28'
Solaris = '29'
  SunOS = '30'
  U6000 = '31'
ASERIES = '32'
TandemNSK = '33'
TandemNT = '34'
 BS2000 = '35'
  LINUX = '36'
   Lynx = '37'
  XENIX = '38'
 VM/ESA = '39'
Interactive UNIX = '40'
BSDUNIX = '41'
FreeBSD = '42'
 NetBSD = '43'
GNU Hurd = '44'
    OS9 = '45'
MACH Kernel = '46'
Inferno = '47'
    QNX = '48'
   EPOC = '49'
IxWorks = '50'
VxWorks = '51'
   MiNT = '52'
   BeOS = '53'
 HP MPE = '54'
NextStep = '55'
PalmPilot = '56'
Rhapsody = '57'
}

#endregion define hashtable

#region define calculated property (to be used with Select-Object)

<#
  a calculated property is defined by a hashtable with keys "Name" and "Expression"
  "Name" defines the name of the property (in this example, it is "TargetOperatingSystem", but you can rename it to anything else)
  "Expression" defines a scriptblock that calculates the content of this property
  in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
  value to its friendly text counterpart:
#>
 
$TargetOperatingSystem = @{
  Name = 'TargetOperatingSystem'
  Expression = {
    # property is an array, so process all values
    $value = $_.TargetOperatingSystem
    $TargetOperatingSystem_map[[int]$value]
  }  
}
#endregion define calculated property

# retrieve the instances, and output the properties "Caption" and "TargetOperatingSystem". The latter
# is defined by the hashtable in $TargetOperatingSystem: 
Get-CimInstance -Class Win32_DirectorySpecification | Select-Object -Property Caption, $TargetOperatingSystem

# ...or dump content of property TargetOperatingSystem:
$friendlyValues = Get-CimInstance -Class Win32_DirectorySpecification | 
    Select-Object -Property $TargetOperatingSystem |
    Select-Object -ExpandProperty TargetOperatingSystem

# output values
$friendlyValues

# output values as comma separated list
$friendlyValues -join ', '

# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $TargetOperatingSystem_map to directly translate raw values from an instance
<# 
  this example uses a hashtable to manually translate raw numeric values 
  for property "Win32_DirectorySpecification" to friendly text. This approach is ideal when
  there is just one instance to work with.

  Note: to use other properties than "Win32_DirectorySpecification", look up the appropriate 
  translation hashtable for the property you would like to use instead.
#>

#region define hashtable to translate raw values to friendly text

# Please note: this hashtable is specific for property "Win32_DirectorySpecification" 
# to translate other properties, use their translation table instead
$TargetOperatingSystem_map = @{
Unknown = '0'
  Other = '1'
  MACOS = '2'
ATTUNIX = '3'
   DGUX = '4'
  DECNT = '5'
Digital UNIX = '6'
OpenVMS = '7'
   HPUX = '8'
    AIX = '9'
    MVS = '10'
  OS400 = '11'
   OS/2 = '12'
 JavaVM = '13'
  MSDOS = '14'
  WIN3x = '15'
  WIN95 = '16'
  WIN98 = '17'
  WINNT = '18'
  WINCE = '19'
NCR3000 = '20'
NetWare = '21'
    OSF = '22'
  DC/OS = '23'
Reliant UNIX = '24'
SCO UnixWare = '25'
SCO OpenServer = '26'
Sequent = '27'
   IRIX = '28'
Solaris = '29'
  SunOS = '30'
  U6000 = '31'
ASERIES = '32'
TandemNSK = '33'
TandemNT = '34'
 BS2000 = '35'
  LINUX = '36'
   Lynx = '37'
  XENIX = '38'
 VM/ESA = '39'
Interactive UNIX = '40'
BSDUNIX = '41'
FreeBSD = '42'
 NetBSD = '43'
GNU Hurd = '44'
    OS9 = '45'
MACH Kernel = '46'
Inferno = '47'
    QNX = '48'
   EPOC = '49'
IxWorks = '50'
VxWorks = '51'
   MiNT = '52'
   BeOS = '53'
 HP MPE = '54'
NextStep = '55'
PalmPilot = '56'
Rhapsody = '57'
}

#endregion define hashtable

# get one instance:
$instance = Get-CimInstance -Class Win32_DirectorySpecification | Select-Object -First 1

<#
  IMPORTANT: this example processes only one instance to illustrate
  the number-to-text translation. To process all instances, replace
  "Select-Object -First 1" with a "Foreach-Object" loop, and use
  the iterator variable $_ instead of $instance
#>

# query the property
$rawValue = $instance.TargetOperatingSystem  

# translate raw value to friendly text:
$friendlyName = $TargetOperatingSystem_map[[int]$rawValue]

# output value
$friendlyName
Use a switch statement inside a calculated property for Select-Object
<# 
  this example uses a switch clause to translate raw numeric 
  values for property "TargetOperatingSystem" to friendly text. The switch
  clause is embedded into a calculated property so there is
  no need to refer to external variables for translation.

  Note: to use other properties than "TargetOperatingSystem", look up the appropriate 
  translation switch clause for the property you would like to use instead.
#>

#region define calculated property (to be used with Select-Object)

<#
  a calculated property is defined by a hashtable with keys "Name" and "Expression"
  "Name" defines the name of the property (in this example, it is "TargetOperatingSystem", but you can rename it to anything else)
  "Expression" defines a scriptblock that calculates the content of this property
  in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
  value to its friendly text counterpart:
#>
 
$TargetOperatingSystem = @{
  Name = 'TargetOperatingSystem'
  Expression = {
    # property is an array, so process all values
    $value = $_.TargetOperatingSystem
    
    switch([int]$value)
      {
        Unknown    {'0'}
        Other      {'1'}
        MACOS      {'2'}
        ATTUNIX    {'3'}
        DGUX       {'4'}
        DECNT      {'5'}
        Digital UNIX {'6'}
        OpenVMS    {'7'}
        HPUX       {'8'}
        AIX        {'9'}
        MVS        {'10'}
        OS400      {'11'}
        OS/2       {'12'}
        JavaVM     {'13'}
        MSDOS      {'14'}
        WIN3x      {'15'}
        WIN95      {'16'}
        WIN98      {'17'}
        WINNT      {'18'}
        WINCE      {'19'}
        NCR3000    {'20'}
        NetWare    {'21'}
        OSF        {'22'}
        DC/OS      {'23'}
        Reliant UNIX {'24'}
        SCO UnixWare {'25'}
        SCO OpenServer {'26'}
        Sequent    {'27'}
        IRIX       {'28'}
        Solaris    {'29'}
        SunOS      {'30'}
        U6000      {'31'}
        ASERIES    {'32'}
        TandemNSK  {'33'}
        TandemNT   {'34'}
        BS2000     {'35'}
        LINUX      {'36'}
        Lynx       {'37'}
        XENIX      {'38'}
        VM/ESA     {'39'}
        Interactive UNIX {'40'}
        BSDUNIX    {'41'}
        FreeBSD    {'42'}
        NetBSD     {'43'}
        GNU Hurd   {'44'}
        OS9        {'45'}
        MACH Kernel {'46'}
        Inferno    {'47'}
        QNX        {'48'}
        EPOC       {'49'}
        IxWorks    {'50'}
        VxWorks    {'51'}
        MiNT       {'52'}
        BeOS       {'53'}
        HP MPE     {'54'}
        NextStep   {'55'}
        PalmPilot  {'56'}
        Rhapsody   {'57'}
        default    {"$value"}
      }
      
  }  
}
#endregion define calculated property

# retrieve all instances...
Get-CimInstance -ClassName Win32_DirectorySpecification | 
  # ...and output properties "Caption" and "TargetOperatingSystem". The latter is defined
  # by the hashtable in $TargetOperatingSystem:
  Select-Object -Property Caption, $TargetOperatingSystem
Use the Enum from above to auto-translate the code values
<# 
  this example translates raw values by means of type conversion
  the friendly names are defined as enumeration using the
  keyword "enum" (PowerShell 5 or better)
  
  The raw value(s) are translated to friendly text by 
  simply converting them into the enum type.
  
  Note: to use other properties than "Win32_DirectorySpecification", look up the appropriate 
  enum definition for the property you would like to use instead.
#>


#region define enum with value-to-text translation:
Enum EnumTargetOperatingSystem
{
  _0    = Unknown
  _1    = Other
  _2    = MACOS
  _3    = ATTUNIX
  _4    = DGUX
  _5    = DECNT
  _6    = Digital UNIX
  _7    = OpenVMS
  _8    = HPUX
  _9    = AIX
  _10   = MVS
  _11   = OS400
  _12   = OS/2
  _13   = JavaVM
  _14   = MSDOS
  _15   = WIN3x
  _16   = WIN95
  _17   = WIN98
  _18   = WINNT
  _19   = WINCE
  _20   = NCR3000
  _21   = NetWare
  _22   = OSF
  _23   = DC/OS
  _24   = Reliant UNIX
  _25   = SCO UnixWare
  _26   = SCO OpenServer
  _27   = Sequent
  _28   = IRIX
  _29   = Solaris
  _30   = SunOS
  _31   = U6000
  _32   = ASERIES
  _33   = TandemNSK
  _34   = TandemNT
  _35   = BS2000
  _36   = LINUX
  _37   = Lynx
  _38   = XENIX
  _39   = VM/ESA
  _40   = Interactive UNIX
  _41   = BSDUNIX
  _42   = FreeBSD
  _43   = NetBSD
  _44   = GNU Hurd
  _45   = OS9
  _46   = MACH Kernel
  _47   = Inferno
  _48   = QNX
  _49   = EPOC
  _50   = IxWorks
  _51   = VxWorks
  _52   = MiNT
  _53   = BeOS
  _54   = HP MPE
  _55   = NextStep
  _56   = PalmPilot
  _57   = Rhapsody
}

#endregion define enum

# get one instance:
$instance = Get-CimInstance -Class Win32_DirectorySpecification | Select-Object -First 1

<#
  IMPORTANT: this example processes only one instance to focus on
  the number-to-text type conversion. 
  
  To process all instances, replace   "Select-Object -First 1" 
  with a "Foreach-Object" loop, and use the iterator variable 
  $_ instead of $instance
#>

# query the property:
$rawValue = $instance.TargetOperatingSystem

#region using strict type conversion

<#
  Note: strict type conversion fails if the raw value is 
  not defined by the enum. So if the list of allowable values
  was extended and the enum does not match the value,
  an exception is thrown
#>

# convert the property to the enum **TargetOperatingSystem** 
[EnumTargetOperatingSystem]$rawValue 

# get a comma-separated string:
[EnumTargetOperatingSystem]$rawValue -join ',' 
#endregion

#region using operator "-as"

<#
  Note: the operator "-as" accepts values not defined
  by the enum and returns $null instead of throwing
  an exception
#>

$rawValue -as [EnumTargetOperatingSystem]
#endregion

Enums must cover all possible values. If TargetOperatingSystem returns a value that is not defined in the enum, an exception occurs. The exception reports the value that was missing in the enum. To fix, add the missing value to the enum.

Version

STRING

Version of the software element. Version should be in the form .. or ..

Get-CimInstance -ClassName Win32_DirectorySpecification | Select-Object -Property CheckID, Version

Examples

List all instances of Win32_DirectorySpecification
Get-CimInstance -ClassName Win32_DirectorySpecification

Learn more about Get-CimInstance and the deprecated Get-WmiObject.

View all properties
Get-CimInstance -ClassName Win32_DirectorySpecification -Property *
View key properties only
Get-CimInstance -ClassName Win32_DirectorySpecification -KeyOnly

Selecting Properties

To select only some properties, pipe the results to Select-Object -Property a,b,c with a comma-separated list of the properties you require. Wildcards are permitted.

Get-CimInstance always returns all properties but only retrieves the ones that you specify. All other properties are empty but still present. That’s why you need to pipe the results into Select-Object if you want to limit the visible properties, i.e. for reporting.

Selecting Properties

The code below lists all available properties. Remove the ones you do not need:

$properties = 'Caption',
              'CheckID',
              'CheckMode',
              'DefaultDir',
              'Description',
              'Directory',
              'DirectoryPath',
              'DirectoryType',
              'Name',
              'SoftwareElementID',
              'SoftwareElementState',
              'TargetOperatingSystem',
              'Version'
Get-CimInstance -ClassName Win32_DirectorySpecification | Select-Object -Property $properties
Limiting Network Bandwidth

If you work remotely, it makes sense to limit network bandwidth by filtering the properties on the server side, too:

Get-CimInstance -Class Win32_DirectorySpecification -Property $property | 
Select-Object -Property $property

Selecting Instances

To select some instances, use Get-CimInstance and a WMI Query. The wildcard character in WMI Queries is % (and not “*”).

The parameter -Filter runs a simple query.

Listing all instances where the property Caption starts with “A”
Get-CimInstance -Class Win32_DirectorySpecification -Filter 'Caption LIKE "a%"' 
Using a WQL Query

The parameter -Query uses a query similar to SQL and combines the parameters -Filter and -Property. This returns all instances where the property Caption starts with “A”, and returns the properties specified:

Get-CimInstance -Query "SELECT CheckID, DefaultDir, Directory, SoftwareElementState FROM Win32_DirectorySpecification WHERE Caption LIKE 'a%'"

Any property you did not specify is still present but empty. You might need to use Select-Object to remove all unwanted properties:

Get-CimInstance -Query "SELECT CheckID, DefaultDir, Directory, SoftwareElementState FROM Win32_DirectorySpecification WHERE Caption LIKE 'a%'" | Select-Object -Property CheckID, DefaultDir, Directory, SoftwareElementState

Accessing Remote Computers

To access remote systems, you need to have proper permissions. User the parameter -ComputerName to access one or more remote systems.

Authenticating as Current User
# one or more computer names or IP addresses:
$list = 'server1', 'server2'

# authenticate with your current identity:
$result = Get-CimInstance -ClassName Win32_DirectorySpecification -ComputerName $list 
$result
Authenticating as Different User

Use a CIMSession object to authenticate with a new identity:

# one or more computer names or IP addresses:
$list = 'server1', 'server2'

# authenticate with a different identity:
$cred = Get-Credential -Message 'Authenticate to retrieve WMI information:'
$session = New-CimSession -ComputerName $list -Credential $cred

$result = Get-CimInstance Win32_DirectorySpecification -CimSession $session

# remove the session after use (if you do not plan to re-use it later)
Remove-CimSession -CimSession $session

$result

Learn more about accessing remote computers.

Requirements

To use Win32_DirectorySpecification, the following requirements apply:

PowerShell

Get-CimInstance was introduced with PowerShell Version 3.0, which in turn was introduced on clients with Windows 8 and on servers with Windows Server 2012.

If necessary, update Windows PowerShell to Windows PowerShell 5.1, or install PowerShell 7 side-by-side.

Operating System

Win32_DirectorySpecification was introduced on clients with Windows XP and on servers with Windows Server 2003.

Namespace

Win32_DirectorySpecification lives in the Namespace Root/CIMV2. This is the default namespace. There is no need to use the -Namespace parameter in Get-CimInstance.

Implementation

Win32_DirectorySpecification is implemented in Msiprov.dll and defined in Msi.mof. Both files are located in the folder C:\Windows\system32\wbem:

explorer $env:windir\system32\wbem
notepad $env:windir\system32\wbem\Msi.mof