The Win32_Printer WMI class represents a device connected to a computer running on a Microsoft Windows operating system that can produce a printed image or text on paper or other medium.
Methods
Win32_Printer has 9 methods:
Method | Description |
---|---|
AddPrinterConnection | Adds a connection to the printer. |
CancelAllJobs | Cancels all jobs. |
GetSecurityDescriptor | Returns the security descriptor that controls access to the printer. |
Pause | Pauses the print queue. |
PrintTestPage | Prints a test page. |
RenamePrinter | Renames a printer. |
Resume | Resumes paused print queue. |
SetDefaultPrinter | Sets the default printer. |
SetSecurityDescriptor | Writes an updated version of the security descriptor that controls access to the printer. |
Learn more about Invoke-CimMethod
and how to invoke commands. Click any of the methods listed above to learn more about their purpose, parameters, and return value.
Properties
Win32_Printer returns 86 properties:
'Attributes','Availability','AvailableJobSheets','AveragePagesPerMinute',
'Capabilities','CapabilityDescriptions','Caption','CharSetsSupported','Comment',
'ConfigManagerErrorCode','ConfigManagerUserConfig','CreationClassName','CurrentCapabilities',
'CurrentCharSet','CurrentLanguage','CurrentMimeType','CurrentNaturalLanguage','CurrentPaperType',
'Default','DefaultCapabilities','DefaultCopies','DefaultLanguage','DefaultMimeType',
'DefaultNumberUp','DefaultPaperType','DefaultPriority','Description','DetectedErrorState','DeviceID',
'Direct','DoCompleteFirst','DriverName','EnableBIDI','EnableDevQueryPrint','ErrorCleared',
'ErrorDescription','ErrorInformation','ExtendedDetectedErrorState','ExtendedPrinterStatus','Hidden',
'HorizontalResolution','InstallDate','JobCountSinceLastReset','KeepPrintedJobs','LanguagesSupported',
'LastErrorCode','Local','Location','MarkingTechnology','MaxCopies','MaxNumberUp','MaxSizeSupported',
'MimeTypesSupported','Name','NaturalLanguagesSupported','Network','PaperSizesSupported',
'PaperTypesAvailable','Parameters','PNPDeviceID','PortName','PowerManagementCapabilities',
'PowerManagementSupported','PrinterPaperNames','PrinterState','PrinterStatus','PrintJobDataType',
'PrintProcessor','Priority','Published','Queued','RawOnly','SeparatorFile','ServerName','Shared',
'ShareName','SpoolEnabled','StartTime','Status','StatusInfo','SystemCreationClassName',
'SystemName','TimeOfLastReset','UntilTime','VerticalResolution','WorkOffline'
Unless explicitly marked as writeable, all properties are read-only. Read all properties for all instances:
Get-CimInstance -ClassName Win32_Printer -Property *
Most WMI classes return one or more instances.
When
Get-CimInstance
returns no result, then apparently no instances of class Win32_Printer 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).
Attributes
Bitmap of attributes for a Windows-based printing device.
Queued
Print jobs are buffered and queued.
Direct
Document to be sent directly to the printer. This value is used if print jobs are not queued correctly.
Default
Default printer on a computer.
Shared
Available as a shared network resource.
Network
Attached to a network. If both Local and Network bits are set, this indicates a network printer.
Hidden
Hidden from some users on the network.
Local
Directly connected to a computer. If both Local and Network bits are set, this indicates a network printer.
EnableDevQ
Enable the queue on the printer if available.
KeepPrintedJobs
Spooler should not delete documents after they are printed.
DoCompleteFirst
Start jobs that are finished spooling first.
WorkOffline
Queue print jobs when a printer is not available.
EnableBIDI
Enable bidirectional printing.
Allow only raw data type jobs to be spooled.
Published
Published in the network directory service.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property Attributes
Availability
Availability and status of the device.
Availability returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$Availability_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Running/Full Power'
4 = 'Warning'
5 = 'In Test'
6 = 'Not Applicable'
7 = 'Power Off'
8 = 'Off Line'
9 = 'Off Duty'
10 = 'Degraded'
11 = 'Not Installed'
12 = 'Install Error'
13 = 'Power Save - Unknown'
14 = 'Power Save - Low Power Mode'
15 = 'Power Save - Standby'
16 = 'Power Cycle'
17 = 'Power Save - Warning'
18 = 'Paused'
19 = 'Not Ready'
20 = 'Not Configured'
21 = 'Quiesced'
}
Use a switch statement
switch([int]$value)
{
1 {'Other'}
2 {'Unknown'}
3 {'Running/Full Power'}
4 {'Warning'}
5 {'In Test'}
6 {'Not Applicable'}
7 {'Power Off'}
8 {'Off Line'}
9 {'Off Duty'}
10 {'Degraded'}
11 {'Not Installed'}
12 {'Install Error'}
13 {'Power Save - Unknown'}
14 {'Power Save - Low Power Mode'}
15 {'Power Save - Standby'}
16 {'Power Cycle'}
17 {'Power Save - Warning'}
18 {'Paused'}
19 {'Not Ready'}
20 {'Not Configured'}
21 {'Quiesced'}
default {"$value"}
}
Use Enum structure
Enum EnumAvailability
{
Other = 1
Unknown = 2
RunningFull_Power = 3
Warning = 4
In_Test = 5
Not_Applicable = 6
Power_Off = 7
Off_Line = 8
Off_Duty = 9
Degraded = 10
Not_Installed = 11
Install_Error = 12
Power_Save_Unknown = 13
Power_Save_Low_Power_Mode = 14
Power_Save_Standby = 15
Power_Cycle = 16
Power_Save_Warning = 17
Paused = 18
Not_Ready = 19
Not_Configured = 20
Quiesced = 21
}
Examples
Use $Availability_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "Availability" to friendly text
Note: to use other properties than "Availability", 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 "Availability"
# to translate other properties, use their translation table instead
$Availability_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Running/Full Power'
4 = 'Warning'
5 = 'In Test'
6 = 'Not Applicable'
7 = 'Power Off'
8 = 'Off Line'
9 = 'Off Duty'
10 = 'Degraded'
11 = 'Not Installed'
12 = 'Install Error'
13 = 'Power Save - Unknown'
14 = 'Power Save - Low Power Mode'
15 = 'Power Save - Standby'
16 = 'Power Cycle'
17 = 'Power Save - Warning'
18 = 'Paused'
19 = 'Not Ready'
20 = 'Not Configured'
21 = 'Quiesced'
}
#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 "Availability", 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:
#>
$Availability = @{
Name = 'Availability'
Expression = {
# property is an array, so process all values
$value = $_.Availability
$Availability_map[[int]$value]
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "Availability". The latter
# is defined by the hashtable in $Availability:
Get-CimInstance -Class Win32_Printer | Select-Object -Property Caption, $Availability
# ...or dump content of property Availability:
$friendlyValues = Get-CimInstance -Class Win32_Printer |
Select-Object -Property $Availability |
Select-Object -ExpandProperty Availability
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $Availability_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_Printer" to friendly text. This approach is ideal when
there is just one instance to work with.
Note: to use other properties than "Win32_Printer", 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_Printer"
# to translate other properties, use their translation table instead
$Availability_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Running/Full Power'
4 = 'Warning'
5 = 'In Test'
6 = 'Not Applicable'
7 = 'Power Off'
8 = 'Off Line'
9 = 'Off Duty'
10 = 'Degraded'
11 = 'Not Installed'
12 = 'Install Error'
13 = 'Power Save - Unknown'
14 = 'Power Save - Low Power Mode'
15 = 'Power Save - Standby'
16 = 'Power Cycle'
17 = 'Power Save - Warning'
18 = 'Paused'
19 = 'Not Ready'
20 = 'Not Configured'
21 = 'Quiesced'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_Printer | 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.Availability
# translate raw value to friendly text:
$friendlyName = $Availability_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 "Availability" 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 "Availability", 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 "Availability", 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:
#>
$Availability = @{
Name = 'Availability'
Expression = {
# property is an array, so process all values
$value = $_.Availability
switch([int]$value)
{
1 {'Other'}
2 {'Unknown'}
3 {'Running/Full Power'}
4 {'Warning'}
5 {'In Test'}
6 {'Not Applicable'}
7 {'Power Off'}
8 {'Off Line'}
9 {'Off Duty'}
10 {'Degraded'}
11 {'Not Installed'}
12 {'Install Error'}
13 {'Power Save - Unknown'}
14 {'Power Save - Low Power Mode'}
15 {'Power Save - Standby'}
16 {'Power Cycle'}
17 {'Power Save - Warning'}
18 {'Paused'}
19 {'Not Ready'}
20 {'Not Configured'}
21 {'Quiesced'}
default {"$value"}
}
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_Printer |
# ...and output properties "Caption" and "Availability". The latter is defined
# by the hashtable in $Availability:
Select-Object -Property Caption, $Availability
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_Printer", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumAvailability
{
Other = 1
Unknown = 2
RunningFull_Power = 3
Warning = 4
In_Test = 5
Not_Applicable = 6
Power_Off = 7
Off_Line = 8
Off_Duty = 9
Degraded = 10
Not_Installed = 11
Install_Error = 12
Power_Save_Unknown = 13
Power_Save_Low_Power_Mode = 14
Power_Save_Standby = 15
Power_Cycle = 16
Power_Save_Warning = 17
Paused = 18
Not_Ready = 19
Not_Configured = 20
Quiesced = 21
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_Printer | 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.Availability
#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 **Availability**
[EnumAvailability]$rawValue
# get a comma-separated string:
[EnumAvailability]$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 [EnumAvailability]
#endregion
Enums must cover all possible values. If Availability 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.
AvailableJobSheets
Array of all the job sheets available on a printer. Can also be used to describe the banner that a printer might provide at the beginning of each job, or other user-specified options.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property AvailableJobSheets
AveragePagesPerMinute
Printing rate, in average number of pages per minute, that a printer can produce output.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property AveragePagesPerMinute
Capabilities
Array of printer capabilities.
Capabilities returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$Capabilities_map = @{
0 = 'Unknown'
1 = 'Other'
2 = 'Color Printing'
3 = 'Duplex Printing'
4 = 'Copies'
5 = 'Collation'
6 = 'Stapling'
7 = 'Transparency Printing'
8 = 'Punch'
9 = 'Cover'
10 = 'Bind'
11 = 'Black and White Printing'
12 = 'One Sided'
13 = 'Two Sided Long Edge'
14 = 'Two Sided Short Edge'
15 = 'Portrait'
16 = 'Landscape'
17 = 'Reverse Portrait'
18 = 'Reverse Landscape'
19 = 'Quality High'
20 = 'Quality Normal'
21 = 'Quality Low'
}
Use a switch statement
switch([int]$value)
{
0 {'Unknown'}
1 {'Other'}
2 {'Color Printing'}
3 {'Duplex Printing'}
4 {'Copies'}
5 {'Collation'}
6 {'Stapling'}
7 {'Transparency Printing'}
8 {'Punch'}
9 {'Cover'}
10 {'Bind'}
11 {'Black and White Printing'}
12 {'One Sided'}
13 {'Two Sided Long Edge'}
14 {'Two Sided Short Edge'}
15 {'Portrait'}
16 {'Landscape'}
17 {'Reverse Portrait'}
18 {'Reverse Landscape'}
19 {'Quality High'}
20 {'Quality Normal'}
21 {'Quality Low'}
default {"$value"}
}
Use Enum structure
Enum EnumCapabilities
{
Unknown = 0
Other = 1
Color_Printing = 2
Duplex_Printing = 3
Copies = 4
Collation = 5
Stapling = 6
Transparency_Printing = 7
Punch = 8
Cover = 9
Bind = 10
Black_and_White_Printing = 11
One_Sided = 12
Two_Sided_Long_Edge = 13
Two_Sided_Short_Edge = 14
Portrait = 15
Landscape = 16
Reverse_Portrait = 17
Reverse_Landscape = 18
Quality_High = 19
Quality_Normal = 20
Quality_Low = 21
}
Examples
Use $Capabilities_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "Capabilities" to friendly text
Note: to use other properties than "Capabilities", 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 "Capabilities"
# to translate other properties, use their translation table instead
$Capabilities_map = @{
0 = 'Unknown'
1 = 'Other'
2 = 'Color Printing'
3 = 'Duplex Printing'
4 = 'Copies'
5 = 'Collation'
6 = 'Stapling'
7 = 'Transparency Printing'
8 = 'Punch'
9 = 'Cover'
10 = 'Bind'
11 = 'Black and White Printing'
12 = 'One Sided'
13 = 'Two Sided Long Edge'
14 = 'Two Sided Short Edge'
15 = 'Portrait'
16 = 'Landscape'
17 = 'Reverse Portrait'
18 = 'Reverse Landscape'
19 = 'Quality High'
20 = 'Quality Normal'
21 = 'Quality Low'
}
#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 "Capabilities", 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:
#>
$Capabilities = @{
Name = 'Capabilities'
Expression = {
# property is an array, so process all values
$result = foreach($value in $_.Capabilities)
{
# important: convert original value to [int] because
# hashtable keys are type-aware:
$Capabilities_map[[int]$value]
}
# uncomment to get a comma-separated string instead
# of a string array:
$result <#-join ', '#>
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "Capabilities". The latter
# is defined by the hashtable in $Capabilities:
Get-CimInstance -Class Win32_Printer | Select-Object -Property Caption, $Capabilities
# ...or dump content of property Capabilities:
$friendlyValues = Get-CimInstance -Class Win32_Printer |
Select-Object -Property $Capabilities |
Select-Object -ExpandProperty Capabilities
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $Capabilities_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_Printer" to friendly text. This approach is ideal when there
is just one instance to work with.
Note: to use other properties than "Win32_Printer", 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_Printer"
# to translate other properties, use their translation table instead
$Capabilities_map = @{
0 = 'Unknown'
1 = 'Other'
2 = 'Color Printing'
3 = 'Duplex Printing'
4 = 'Copies'
5 = 'Collation'
6 = 'Stapling'
7 = 'Transparency Printing'
8 = 'Punch'
9 = 'Cover'
10 = 'Bind'
11 = 'Black and White Printing'
12 = 'One Sided'
13 = 'Two Sided Long Edge'
14 = 'Two Sided Short Edge'
15 = 'Portrait'
16 = 'Landscape'
17 = 'Reverse Portrait'
18 = 'Reverse Landscape'
19 = 'Quality High'
20 = 'Quality Normal'
21 = 'Quality Low'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_Printer | 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 (hint: the property is an array!)
$rawValues = $instance.Capabilities
# translate all raw values into friendly names:
$friendlyNames = foreach($rawValue in $rawValues)
{ $Capabilities_map[[int]$rawValue] }
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use a switch statement inside a calculated property for Select-Object
<#
this example uses a switch clause to translate raw numeric
values for property "Capabilities" 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 "Capabilities", 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 "Capabilities", 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:
#>
$Capabilities = @{
Name = 'Capabilities'
Expression = {
# property is an array, so process all values
$result = foreach($value in $_.Capabilities)
{
switch([int]$value)
{
0 {'Unknown'}
1 {'Other'}
2 {'Color Printing'}
3 {'Duplex Printing'}
4 {'Copies'}
5 {'Collation'}
6 {'Stapling'}
7 {'Transparency Printing'}
8 {'Punch'}
9 {'Cover'}
10 {'Bind'}
11 {'Black and White Printing'}
12 {'One Sided'}
13 {'Two Sided Long Edge'}
14 {'Two Sided Short Edge'}
15 {'Portrait'}
16 {'Landscape'}
17 {'Reverse Portrait'}
18 {'Reverse Landscape'}
19 {'Quality High'}
20 {'Quality Normal'}
21 {'Quality Low'}
default {"$value"}
}
}
$result
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_Printer |
# ...and output properties "Caption" and "Capabilities". The latter is defined
# by the hashtable in $Capabilities:
Select-Object -Property Caption, $Capabilities
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_Printer", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumCapabilities
{
Unknown = 0
Other = 1
Color_Printing = 2
Duplex_Printing = 3
Copies = 4
Collation = 5
Stapling = 6
Transparency_Printing = 7
Punch = 8
Cover = 9
Bind = 10
Black_and_White_Printing = 11
One_Sided = 12
Two_Sided_Long_Edge = 13
Two_Sided_Short_Edge = 14
Portrait = 15
Landscape = 16
Reverse_Portrait = 17
Reverse_Landscape = 18
Quality_High = 19
Quality_Normal = 20
Quality_Low = 21
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_Printer | 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.Capabilities
#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 **Capabilities**
[EnumCapabilities[]]$rawValue
# get a comma-separated string:
[EnumCapabilities[]]$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 [EnumCapabilities[]]
#endregion
Enums must cover all possible values. If Capabilities 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.
CapabilityDescriptions
Array of free-form strings that provide detailed explanations for the printer features indicated in the Capabilities array. Each entry of this array is related to an entry in the Capabilities array that is located in the same index.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property CapabilityDescriptions
Caption
Short description of an objectâa one-line string.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property Caption
CharSetsSupported
Array of available character sets for output. Strings provided in this property must conform to the semantics and syntax specified by section 4.1.2 (“Charset parameters”) in RFC 2046 (MIME Part 2) and contained in the IANA character-set registry. Examples include, “UTF-8”, “us-ASCII”, and “iso-8859-1”.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property CharSetsSupported
Comment
Comment for a print queue.
Example: Color printer
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property Comment
ConfigManagerErrorCode
Win32 Configuration Manager error code.
ConfigManagerErrorCode returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$ConfigManagerErrorCode_map = @{
0 = 'This device is working properly.'
1 = 'This device is not configured correctly.'
2 = 'Windows cannot load the driver for this device.'
3 = 'The driver for this device might be corrupted, or your system may be running low on memory or other resources.'
4 = 'This device is not working properly. One of its drivers or your registry might be corrupted.'
5 = 'The driver for this device needs a resource that Windows cannot manage.'
6 = 'The boot configuration for this device conflicts with other devices.'
7 = 'Cannot filter.'
8 = 'The driver loader for the device is missing.'
9 = 'This device is not working properly because the controlling firmware is reporting the resources for the device incorrectly.'
10 = 'This device cannot start.'
11 = 'This device failed.'
12 = 'This device cannot find enough free resources that it can use.'
13 = 'Windows cannot verify this device''s resources.'
14 = 'This device cannot work properly until you restart your computer.'
15 = 'This device is not working properly because there is probably a re-enumeration problem.'
16 = 'Windows cannot identify all the resources this device uses.'
17 = 'This device is asking for an unknown resource type.'
18 = 'Reinstall the drivers for this device.'
19 = 'Failure using the VxD loader.'
20 = 'Your registry might be corrupted.'
21 = 'System failure: Try changing the driver for this device. If that does not work, see your hardware documentation. Windows is removing this device.'
22 = 'This device is disabled.'
23 = 'System failure: Try changing the driver for this device. If that doesn''t work, see your hardware documentation.'
24 = 'This device is not present, is not working properly, or does not have all its drivers installed.'
25 = 'Windows is still setting up this device.'
26 = 'Windows is still setting up this device.'
27 = 'This device does not have valid log configuration.'
28 = 'The drivers for this device are not installed.'
29 = 'This device is disabled because the firmware of the device did not give it the required resources.'
30 = 'This device is using an Interrupt Request (IRQ) resource that another device is using.'
31 = 'This device is not working properly because Windows cannot load the drivers required for this device.'
}
Use a switch statement
switch([int]$value)
{
0 {'This device is working properly.'}
1 {'This device is not configured correctly.'}
2 {'Windows cannot load the driver for this device.'}
3 {'The driver for this device might be corrupted, or your system may be running low on memory or other resources.'}
4 {'This device is not working properly. One of its drivers or your registry might be corrupted.'}
5 {'The driver for this device needs a resource that Windows cannot manage.'}
6 {'The boot configuration for this device conflicts with other devices.'}
7 {'Cannot filter.'}
8 {'The driver loader for the device is missing.'}
9 {'This device is not working properly because the controlling firmware is reporting the resources for the device incorrectly.'}
10 {'This device cannot start.'}
11 {'This device failed.'}
12 {'This device cannot find enough free resources that it can use.'}
13 {'Windows cannot verify this device''s resources.'}
14 {'This device cannot work properly until you restart your computer.'}
15 {'This device is not working properly because there is probably a re-enumeration problem.'}
16 {'Windows cannot identify all the resources this device uses.'}
17 {'This device is asking for an unknown resource type.'}
18 {'Reinstall the drivers for this device.'}
19 {'Failure using the VxD loader.'}
20 {'Your registry might be corrupted.'}
21 {'System failure: Try changing the driver for this device. If that does not work, see your hardware documentation. Windows is removing this device.'}
22 {'This device is disabled.'}
23 {'System failure: Try changing the driver for this device. If that doesn''t work, see your hardware documentation.'}
24 {'This device is not present, is not working properly, or does not have all its drivers installed.'}
25 {'Windows is still setting up this device.'}
26 {'Windows is still setting up this device.'}
27 {'This device does not have valid log configuration.'}
28 {'The drivers for this device are not installed.'}
29 {'This device is disabled because the firmware of the device did not give it the required resources.'}
30 {'This device is using an Interrupt Request (IRQ) resource that another device is using.'}
31 {'This device is not working properly because Windows cannot load the drivers required for this device.'}
default {"$value"}
}
Use Enum structure
Enum EnumConfigManagerErrorCode
{
This_device_is_working_properly = 0
This_device_is_not_configured_correctly = 1
Windows_cannot_load_the_driver_for_this_device = 2
The_driver_for_this_device_might_be_corrupted_or_your_system_may_be_running_low_on_memory_or_other_resources = 3
This_device_is_not_working_properly_One_of_its_drivers_or_your_registry_might_be_corrupted = 4
The_driver_for_this_device_needs_a_resource_that_Windows_cannot_manage = 5
The_boot_configuration_for_this_device_conflicts_with_other_devices = 6
Cannot_filter = 7
The_driver_loader_for_the_device_is_missing = 8
This_device_is_not_working_properly_because_the_controlling_firmware_is_reporting_the_resources_for_the_device_incorrectly = 9
This_device_cannot_start = 10
This_device_failed = 11
This_device_cannot_find_enough_free_resources_that_it_can_use = 12
Windows_cannot_verify_this_devices_resources = 13
This_device_cannot_work_properly_until_you_restart_your_computer = 14
This_device_is_not_working_properly_because_there_is_probably_a_re_enumeration_problem = 15
Windows_cannot_identify_all_the_resources_this_device_uses = 16
This_device_is_asking_for_an_unknown_resource_type = 17
Reinstall_the_drivers_for_this_device = 18
Failure_using_the_VxD_loader = 19
Your_registry_might_be_corrupted = 20
System_failure_Try_changing_the_driver_for_this_device_If_that_does_not_work_see_your_hardware_documentation_Windows_is_removing_this_device = 21
This_device_is_disabled = 22
System_failure_Try_changing_the_driver_for_this_device_If_that_doesnt_work_see_your_hardware_documentation = 23
This_device_is_not_present_is_not_working_properly_or_does_not_have_all_its_drivers_installed = 24
Windows_is_still_setting_up_this_device1 = 25
Windows_is_still_setting_up_this_device2 = 26
This_device_does_not_have_valid_log_configuration = 27
The_drivers_for_this_device_are_not_installed = 28
This_device_is_disabled_because_the_firmware_of_the_device_did_not_give_it_the_required_resources = 29
This_device_is_using_an_Interrupt_Request_IRQ_resource_that_another_device_is_using = 30
This_device_is_not_working_properly_because_Windows_cannot_load_the_drivers_required_for_this_device = 31
}
Examples
Use $ConfigManagerErrorCode_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "ConfigManagerErrorCode" to friendly text
Note: to use other properties than "ConfigManagerErrorCode", 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 "ConfigManagerErrorCode"
# to translate other properties, use their translation table instead
$ConfigManagerErrorCode_map = @{
0 = 'This device is working properly.'
1 = 'This device is not configured correctly.'
2 = 'Windows cannot load the driver for this device.'
3 = 'The driver for this device might be corrupted, or your system may be running low on memory or other resources.'
4 = 'This device is not working properly. One of its drivers or your registry might be corrupted.'
5 = 'The driver for this device needs a resource that Windows cannot manage.'
6 = 'The boot configuration for this device conflicts with other devices.'
7 = 'Cannot filter.'
8 = 'The driver loader for the device is missing.'
9 = 'This device is not working properly because the controlling firmware is reporting the resources for the device incorrectly.'
10 = 'This device cannot start.'
11 = 'This device failed.'
12 = 'This device cannot find enough free resources that it can use.'
13 = 'Windows cannot verify this device''s resources.'
14 = 'This device cannot work properly until you restart your computer.'
15 = 'This device is not working properly because there is probably a re-enumeration problem.'
16 = 'Windows cannot identify all the resources this device uses.'
17 = 'This device is asking for an unknown resource type.'
18 = 'Reinstall the drivers for this device.'
19 = 'Failure using the VxD loader.'
20 = 'Your registry might be corrupted.'
21 = 'System failure: Try changing the driver for this device. If that does not work, see your hardware documentation. Windows is removing this device.'
22 = 'This device is disabled.'
23 = 'System failure: Try changing the driver for this device. If that doesn''t work, see your hardware documentation.'
24 = 'This device is not present, is not working properly, or does not have all its drivers installed.'
25 = 'Windows is still setting up this device.'
26 = 'Windows is still setting up this device.'
27 = 'This device does not have valid log configuration.'
28 = 'The drivers for this device are not installed.'
29 = 'This device is disabled because the firmware of the device did not give it the required resources.'
30 = 'This device is using an Interrupt Request (IRQ) resource that another device is using.'
31 = 'This device is not working properly because Windows cannot load the drivers required for this device.'
}
#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 "ConfigManagerErrorCode", 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:
#>
$ConfigManagerErrorCode = @{
Name = 'ConfigManagerErrorCode'
Expression = {
# property is an array, so process all values
$value = $_.ConfigManagerErrorCode
$ConfigManagerErrorCode_map[[int]$value]
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "ConfigManagerErrorCode". The latter
# is defined by the hashtable in $ConfigManagerErrorCode:
Get-CimInstance -Class Win32_Printer | Select-Object -Property Caption, $ConfigManagerErrorCode
# ...or dump content of property ConfigManagerErrorCode:
$friendlyValues = Get-CimInstance -Class Win32_Printer |
Select-Object -Property $ConfigManagerErrorCode |
Select-Object -ExpandProperty ConfigManagerErrorCode
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $ConfigManagerErrorCode_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_Printer" to friendly text. This approach is ideal when
there is just one instance to work with.
Note: to use other properties than "Win32_Printer", 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_Printer"
# to translate other properties, use their translation table instead
$ConfigManagerErrorCode_map = @{
0 = 'This device is working properly.'
1 = 'This device is not configured correctly.'
2 = 'Windows cannot load the driver for this device.'
3 = 'The driver for this device might be corrupted, or your system may be running low on memory or other resources.'
4 = 'This device is not working properly. One of its drivers or your registry might be corrupted.'
5 = 'The driver for this device needs a resource that Windows cannot manage.'
6 = 'The boot configuration for this device conflicts with other devices.'
7 = 'Cannot filter.'
8 = 'The driver loader for the device is missing.'
9 = 'This device is not working properly because the controlling firmware is reporting the resources for the device incorrectly.'
10 = 'This device cannot start.'
11 = 'This device failed.'
12 = 'This device cannot find enough free resources that it can use.'
13 = 'Windows cannot verify this device''s resources.'
14 = 'This device cannot work properly until you restart your computer.'
15 = 'This device is not working properly because there is probably a re-enumeration problem.'
16 = 'Windows cannot identify all the resources this device uses.'
17 = 'This device is asking for an unknown resource type.'
18 = 'Reinstall the drivers for this device.'
19 = 'Failure using the VxD loader.'
20 = 'Your registry might be corrupted.'
21 = 'System failure: Try changing the driver for this device. If that does not work, see your hardware documentation. Windows is removing this device.'
22 = 'This device is disabled.'
23 = 'System failure: Try changing the driver for this device. If that doesn''t work, see your hardware documentation.'
24 = 'This device is not present, is not working properly, or does not have all its drivers installed.'
25 = 'Windows is still setting up this device.'
26 = 'Windows is still setting up this device.'
27 = 'This device does not have valid log configuration.'
28 = 'The drivers for this device are not installed.'
29 = 'This device is disabled because the firmware of the device did not give it the required resources.'
30 = 'This device is using an Interrupt Request (IRQ) resource that another device is using.'
31 = 'This device is not working properly because Windows cannot load the drivers required for this device.'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_Printer | 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.ConfigManagerErrorCode
# translate raw value to friendly text:
$friendlyName = $ConfigManagerErrorCode_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 "ConfigManagerErrorCode" 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 "ConfigManagerErrorCode", 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 "ConfigManagerErrorCode", 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:
#>
$ConfigManagerErrorCode = @{
Name = 'ConfigManagerErrorCode'
Expression = {
# property is an array, so process all values
$value = $_.ConfigManagerErrorCode
switch([int]$value)
{
0 {'This device is working properly.'}
1 {'This device is not configured correctly.'}
2 {'Windows cannot load the driver for this device.'}
3 {'The driver for this device might be corrupted, or your system may be running low on memory or other resources.'}
4 {'This device is not working properly. One of its drivers or your registry might be corrupted.'}
5 {'The driver for this device needs a resource that Windows cannot manage.'}
6 {'The boot configuration for this device conflicts with other devices.'}
7 {'Cannot filter.'}
8 {'The driver loader for the device is missing.'}
9 {'This device is not working properly because the controlling firmware is reporting the resources for the device incorrectly.'}
10 {'This device cannot start.'}
11 {'This device failed.'}
12 {'This device cannot find enough free resources that it can use.'}
13 {'Windows cannot verify this device''s resources.'}
14 {'This device cannot work properly until you restart your computer.'}
15 {'This device is not working properly because there is probably a re-enumeration problem.'}
16 {'Windows cannot identify all the resources this device uses.'}
17 {'This device is asking for an unknown resource type.'}
18 {'Reinstall the drivers for this device.'}
19 {'Failure using the VxD loader.'}
20 {'Your registry might be corrupted.'}
21 {'System failure: Try changing the driver for this device. If that does not work, see your hardware documentation. Windows is removing this device.'}
22 {'This device is disabled.'}
23 {'System failure: Try changing the driver for this device. If that doesn''t work, see your hardware documentation.'}
24 {'This device is not present, is not working properly, or does not have all its drivers installed.'}
25 {'Windows is still setting up this device.'}
26 {'Windows is still setting up this device.'}
27 {'This device does not have valid log configuration.'}
28 {'The drivers for this device are not installed.'}
29 {'This device is disabled because the firmware of the device did not give it the required resources.'}
30 {'This device is using an Interrupt Request (IRQ) resource that another device is using.'}
31 {'This device is not working properly because Windows cannot load the drivers required for this device.'}
default {"$value"}
}
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_Printer |
# ...and output properties "Caption" and "ConfigManagerErrorCode". The latter is defined
# by the hashtable in $ConfigManagerErrorCode:
Select-Object -Property Caption, $ConfigManagerErrorCode
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_Printer", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumConfigManagerErrorCode
{
This_device_is_working_properly = 0
This_device_is_not_configured_correctly = 1
Windows_cannot_load_the_driver_for_this_device = 2
The_driver_for_this_device_might_be_corrupted_or_your_system_may_be_running_low_on_memory_or_other_resources = 3
This_device_is_not_working_properly_One_of_its_drivers_or_your_registry_might_be_corrupted = 4
The_driver_for_this_device_needs_a_resource_that_Windows_cannot_manage = 5
The_boot_configuration_for_this_device_conflicts_with_other_devices = 6
Cannot_filter = 7
The_driver_loader_for_the_device_is_missing = 8
This_device_is_not_working_properly_because_the_controlling_firmware_is_reporting_the_resources_for_the_device_incorrectly = 9
This_device_cannot_start = 10
This_device_failed = 11
This_device_cannot_find_enough_free_resources_that_it_can_use = 12
Windows_cannot_verify_this_devices_resources = 13
This_device_cannot_work_properly_until_you_restart_your_computer = 14
This_device_is_not_working_properly_because_there_is_probably_a_re_enumeration_problem = 15
Windows_cannot_identify_all_the_resources_this_device_uses = 16
This_device_is_asking_for_an_unknown_resource_type = 17
Reinstall_the_drivers_for_this_device = 18
Failure_using_the_VxD_loader = 19
Your_registry_might_be_corrupted = 20
System_failure_Try_changing_the_driver_for_this_device_If_that_does_not_work_see_your_hardware_documentation_Windows_is_removing_this_device = 21
This_device_is_disabled = 22
System_failure_Try_changing_the_driver_for_this_device_If_that_doesnt_work_see_your_hardware_documentation = 23
This_device_is_not_present_is_not_working_properly_or_does_not_have_all_its_drivers_installed = 24
Windows_is_still_setting_up_this_device1 = 25
Windows_is_still_setting_up_this_device2 = 26
This_device_does_not_have_valid_log_configuration = 27
The_drivers_for_this_device_are_not_installed = 28
This_device_is_disabled_because_the_firmware_of_the_device_did_not_give_it_the_required_resources = 29
This_device_is_using_an_Interrupt_Request_IRQ_resource_that_another_device_is_using = 30
This_device_is_not_working_properly_because_Windows_cannot_load_the_drivers_required_for_this_device = 31
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_Printer | 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.ConfigManagerErrorCode
#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 **ConfigManagerErrorCode**
[EnumConfigManagerErrorCode]$rawValue
# get a comma-separated string:
[EnumConfigManagerErrorCode]$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 [EnumConfigManagerErrorCode]
#endregion
Enums must cover all possible values. If ConfigManagerErrorCode 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.
ConfigManagerUserConfig
If TRUE, the device is using a user-defined configuration.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property ConfigManagerUserConfig
CreationClassName
Name of the first concrete class to appear in the inheritance chain used to create an instance. When used with other key properties of the class, the property allows all instances of this class and its subclasses to be identified uniquely.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property CreationClassName
CurrentCapabilities
Array of printer capabilities that are being used currently. An entry in this property must also be listed in the Capabilities array.
CurrentCapabilities returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$CurrentCapabilities_map = @{
0 = 'Unknown'
1 = 'Other'
2 = 'Color Printing'
3 = 'Duplex Printing'
4 = 'Copies'
5 = 'Collation'
6 = 'Stapling'
7 = 'Transparency Printing'
8 = 'Punch'
9 = 'Cover'
10 = 'Bind'
11 = 'Black and White Printing'
12 = 'One Sided'
13 = 'Two Sided Long Edge'
14 = 'Two Sided Short Edge'
15 = 'Portrait'
16 = 'Landscape'
17 = 'Reverse Portrait'
18 = 'Reverse Landscape'
19 = 'Quality High'
20 = 'Quality Normal'
21 = 'Quality Low'
}
Use a switch statement
switch([int]$value)
{
0 {'Unknown'}
1 {'Other'}
2 {'Color Printing'}
3 {'Duplex Printing'}
4 {'Copies'}
5 {'Collation'}
6 {'Stapling'}
7 {'Transparency Printing'}
8 {'Punch'}
9 {'Cover'}
10 {'Bind'}
11 {'Black and White Printing'}
12 {'One Sided'}
13 {'Two Sided Long Edge'}
14 {'Two Sided Short Edge'}
15 {'Portrait'}
16 {'Landscape'}
17 {'Reverse Portrait'}
18 {'Reverse Landscape'}
19 {'Quality High'}
20 {'Quality Normal'}
21 {'Quality Low'}
default {"$value"}
}
Use Enum structure
Enum EnumCurrentCapabilities
{
Unknown = 0
Other = 1
Color_Printing = 2
Duplex_Printing = 3
Copies = 4
Collation = 5
Stapling = 6
Transparency_Printing = 7
Punch = 8
Cover = 9
Bind = 10
Black_and_White_Printing = 11
One_Sided = 12
Two_Sided_Long_Edge = 13
Two_Sided_Short_Edge = 14
Portrait = 15
Landscape = 16
Reverse_Portrait = 17
Reverse_Landscape = 18
Quality_High = 19
Quality_Normal = 20
Quality_Low = 21
}
Examples
Use $CurrentCapabilities_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "CurrentCapabilities" to friendly text
Note: to use other properties than "CurrentCapabilities", 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 "CurrentCapabilities"
# to translate other properties, use their translation table instead
$CurrentCapabilities_map = @{
0 = 'Unknown'
1 = 'Other'
2 = 'Color Printing'
3 = 'Duplex Printing'
4 = 'Copies'
5 = 'Collation'
6 = 'Stapling'
7 = 'Transparency Printing'
8 = 'Punch'
9 = 'Cover'
10 = 'Bind'
11 = 'Black and White Printing'
12 = 'One Sided'
13 = 'Two Sided Long Edge'
14 = 'Two Sided Short Edge'
15 = 'Portrait'
16 = 'Landscape'
17 = 'Reverse Portrait'
18 = 'Reverse Landscape'
19 = 'Quality High'
20 = 'Quality Normal'
21 = 'Quality Low'
}
#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 "CurrentCapabilities", 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:
#>
$CurrentCapabilities = @{
Name = 'CurrentCapabilities'
Expression = {
# property is an array, so process all values
$result = foreach($value in $_.CurrentCapabilities)
{
# important: convert original value to [int] because
# hashtable keys are type-aware:
$CurrentCapabilities_map[[int]$value]
}
# uncomment to get a comma-separated string instead
# of a string array:
$result <#-join ', '#>
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "CurrentCapabilities". The latter
# is defined by the hashtable in $CurrentCapabilities:
Get-CimInstance -Class Win32_Printer | Select-Object -Property Caption, $CurrentCapabilities
# ...or dump content of property CurrentCapabilities:
$friendlyValues = Get-CimInstance -Class Win32_Printer |
Select-Object -Property $CurrentCapabilities |
Select-Object -ExpandProperty CurrentCapabilities
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $CurrentCapabilities_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_Printer" to friendly text. This approach is ideal when there
is just one instance to work with.
Note: to use other properties than "Win32_Printer", 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_Printer"
# to translate other properties, use their translation table instead
$CurrentCapabilities_map = @{
0 = 'Unknown'
1 = 'Other'
2 = 'Color Printing'
3 = 'Duplex Printing'
4 = 'Copies'
5 = 'Collation'
6 = 'Stapling'
7 = 'Transparency Printing'
8 = 'Punch'
9 = 'Cover'
10 = 'Bind'
11 = 'Black and White Printing'
12 = 'One Sided'
13 = 'Two Sided Long Edge'
14 = 'Two Sided Short Edge'
15 = 'Portrait'
16 = 'Landscape'
17 = 'Reverse Portrait'
18 = 'Reverse Landscape'
19 = 'Quality High'
20 = 'Quality Normal'
21 = 'Quality Low'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_Printer | 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 (hint: the property is an array!)
$rawValues = $instance.CurrentCapabilities
# translate all raw values into friendly names:
$friendlyNames = foreach($rawValue in $rawValues)
{ $CurrentCapabilities_map[[int]$rawValue] }
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use a switch statement inside a calculated property for Select-Object
<#
this example uses a switch clause to translate raw numeric
values for property "CurrentCapabilities" 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 "CurrentCapabilities", 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 "CurrentCapabilities", 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:
#>
$CurrentCapabilities = @{
Name = 'CurrentCapabilities'
Expression = {
# property is an array, so process all values
$result = foreach($value in $_.CurrentCapabilities)
{
switch([int]$value)
{
0 {'Unknown'}
1 {'Other'}
2 {'Color Printing'}
3 {'Duplex Printing'}
4 {'Copies'}
5 {'Collation'}
6 {'Stapling'}
7 {'Transparency Printing'}
8 {'Punch'}
9 {'Cover'}
10 {'Bind'}
11 {'Black and White Printing'}
12 {'One Sided'}
13 {'Two Sided Long Edge'}
14 {'Two Sided Short Edge'}
15 {'Portrait'}
16 {'Landscape'}
17 {'Reverse Portrait'}
18 {'Reverse Landscape'}
19 {'Quality High'}
20 {'Quality Normal'}
21 {'Quality Low'}
default {"$value"}
}
}
$result
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_Printer |
# ...and output properties "Caption" and "CurrentCapabilities". The latter is defined
# by the hashtable in $CurrentCapabilities:
Select-Object -Property Caption, $CurrentCapabilities
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_Printer", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumCurrentCapabilities
{
Unknown = 0
Other = 1
Color_Printing = 2
Duplex_Printing = 3
Copies = 4
Collation = 5
Stapling = 6
Transparency_Printing = 7
Punch = 8
Cover = 9
Bind = 10
Black_and_White_Printing = 11
One_Sided = 12
Two_Sided_Long_Edge = 13
Two_Sided_Short_Edge = 14
Portrait = 15
Landscape = 16
Reverse_Portrait = 17
Reverse_Landscape = 18
Quality_High = 19
Quality_Normal = 20
Quality_Low = 21
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_Printer | 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.CurrentCapabilities
#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 **CurrentCapabilities**
[EnumCurrentCapabilities[]]$rawValue
# get a comma-separated string:
[EnumCurrentCapabilities[]]$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 [EnumCurrentCapabilities[]]
#endregion
Enums must cover all possible values. If CurrentCapabilities 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.
CurrentCharSet
The character set currently used for output. Strings provided in this property must conform to the semantics and syntax specified by section 4.1.2 (“Charset parameters”) in RFC 2046 (MIME Part 2) and contained in the IANA character-set registry. Examples include “utf-8”, “us-ASCII”, and iso-8859-1.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property CurrentCharSet
CurrentLanguage
Printer language currently used. The language used must be listed in the LanguagesSupported property.
CurrentLanguage returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$CurrentLanguage_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'PCL'
4 = 'HPGL'
5 = 'PJL'
6 = 'PS'
7 = 'PSPrinter'
8 = 'IPDS'
9 = 'PPDS'
10 = 'EscapeP'
11 = 'Epson'
12 = 'DDIF'
13 = 'Interpress'
14 = 'ISO6429'
15 = 'Line Data'
16 = 'MODCA'
17 = 'REGIS'
18 = 'SCS'
19 = 'SPDL'
20 = 'TEK4014'
21 = 'PDS'
22 = 'IGP'
23 = 'CodeV'
24 = 'DSCDSE'
25 = 'WPS'
26 = 'LN03'
27 = 'CCITT'
28 = 'QUIC'
29 = 'CPAP'
30 = 'DecPPL'
31 = 'Simple Text'
32 = 'NPAP'
33 = 'DOC'
34 = 'imPress'
35 = 'Pinwriter'
36 = 'NPDL'
37 = 'NEC201PL'
38 = 'Automatic'
39 = 'Pages'
40 = 'LIPS'
41 = 'TIFF'
42 = 'Diagnostic'
43 = 'CaPSL'
44 = 'EXCL'
45 = 'LCDS'
46 = 'XES'
47 = 'MIME'
}
Use a switch statement
switch([int]$value)
{
1 {'Other'}
2 {'Unknown'}
3 {'PCL'}
4 {'HPGL'}
5 {'PJL'}
6 {'PS'}
7 {'PSPrinter'}
8 {'IPDS'}
9 {'PPDS'}
10 {'EscapeP'}
11 {'Epson'}
12 {'DDIF'}
13 {'Interpress'}
14 {'ISO6429'}
15 {'Line Data'}
16 {'MODCA'}
17 {'REGIS'}
18 {'SCS'}
19 {'SPDL'}
20 {'TEK4014'}
21 {'PDS'}
22 {'IGP'}
23 {'CodeV'}
24 {'DSCDSE'}
25 {'WPS'}
26 {'LN03'}
27 {'CCITT'}
28 {'QUIC'}
29 {'CPAP'}
30 {'DecPPL'}
31 {'Simple Text'}
32 {'NPAP'}
33 {'DOC'}
34 {'imPress'}
35 {'Pinwriter'}
36 {'NPDL'}
37 {'NEC201PL'}
38 {'Automatic'}
39 {'Pages'}
40 {'LIPS'}
41 {'TIFF'}
42 {'Diagnostic'}
43 {'CaPSL'}
44 {'EXCL'}
45 {'LCDS'}
46 {'XES'}
47 {'MIME'}
default {"$value"}
}
Use Enum structure
Enum EnumCurrentLanguage
{
Other = 1
Unknown = 2
PCL = 3
HPGL = 4
PJL = 5
PS = 6
PSPrinter = 7
IPDS = 8
PPDS = 9
EscapeP = 10
Epson = 11
DDIF = 12
Interpress = 13
ISO6429 = 14
Line_Data = 15
MODCA = 16
REGIS = 17
SCS = 18
SPDL = 19
TEK4014 = 20
PDS = 21
IGP = 22
CodeV = 23
DSCDSE = 24
WPS = 25
LN03 = 26
CCITT = 27
QUIC = 28
CPAP = 29
DecPPL = 30
Simple_Text = 31
NPAP = 32
DOC = 33
imPress = 34
Pinwriter = 35
NPDL = 36
NEC201PL = 37
Automatic = 38
Pages = 39
LIPS = 40
TIFF = 41
Diagnostic = 42
CaPSL = 43
EXCL = 44
LCDS = 45
XES = 46
MIME = 47
}
Examples
Use $CurrentLanguage_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "CurrentLanguage" to friendly text
Note: to use other properties than "CurrentLanguage", 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 "CurrentLanguage"
# to translate other properties, use their translation table instead
$CurrentLanguage_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'PCL'
4 = 'HPGL'
5 = 'PJL'
6 = 'PS'
7 = 'PSPrinter'
8 = 'IPDS'
9 = 'PPDS'
10 = 'EscapeP'
11 = 'Epson'
12 = 'DDIF'
13 = 'Interpress'
14 = 'ISO6429'
15 = 'Line Data'
16 = 'MODCA'
17 = 'REGIS'
18 = 'SCS'
19 = 'SPDL'
20 = 'TEK4014'
21 = 'PDS'
22 = 'IGP'
23 = 'CodeV'
24 = 'DSCDSE'
25 = 'WPS'
26 = 'LN03'
27 = 'CCITT'
28 = 'QUIC'
29 = 'CPAP'
30 = 'DecPPL'
31 = 'Simple Text'
32 = 'NPAP'
33 = 'DOC'
34 = 'imPress'
35 = 'Pinwriter'
36 = 'NPDL'
37 = 'NEC201PL'
38 = 'Automatic'
39 = 'Pages'
40 = 'LIPS'
41 = 'TIFF'
42 = 'Diagnostic'
43 = 'CaPSL'
44 = 'EXCL'
45 = 'LCDS'
46 = 'XES'
47 = 'MIME'
}
#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 "CurrentLanguage", 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:
#>
$CurrentLanguage = @{
Name = 'CurrentLanguage'
Expression = {
# property is an array, so process all values
$value = $_.CurrentLanguage
$CurrentLanguage_map[[int]$value]
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "CurrentLanguage". The latter
# is defined by the hashtable in $CurrentLanguage:
Get-CimInstance -Class Win32_Printer | Select-Object -Property Caption, $CurrentLanguage
# ...or dump content of property CurrentLanguage:
$friendlyValues = Get-CimInstance -Class Win32_Printer |
Select-Object -Property $CurrentLanguage |
Select-Object -ExpandProperty CurrentLanguage
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $CurrentLanguage_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_Printer" to friendly text. This approach is ideal when
there is just one instance to work with.
Note: to use other properties than "Win32_Printer", 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_Printer"
# to translate other properties, use their translation table instead
$CurrentLanguage_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'PCL'
4 = 'HPGL'
5 = 'PJL'
6 = 'PS'
7 = 'PSPrinter'
8 = 'IPDS'
9 = 'PPDS'
10 = 'EscapeP'
11 = 'Epson'
12 = 'DDIF'
13 = 'Interpress'
14 = 'ISO6429'
15 = 'Line Data'
16 = 'MODCA'
17 = 'REGIS'
18 = 'SCS'
19 = 'SPDL'
20 = 'TEK4014'
21 = 'PDS'
22 = 'IGP'
23 = 'CodeV'
24 = 'DSCDSE'
25 = 'WPS'
26 = 'LN03'
27 = 'CCITT'
28 = 'QUIC'
29 = 'CPAP'
30 = 'DecPPL'
31 = 'Simple Text'
32 = 'NPAP'
33 = 'DOC'
34 = 'imPress'
35 = 'Pinwriter'
36 = 'NPDL'
37 = 'NEC201PL'
38 = 'Automatic'
39 = 'Pages'
40 = 'LIPS'
41 = 'TIFF'
42 = 'Diagnostic'
43 = 'CaPSL'
44 = 'EXCL'
45 = 'LCDS'
46 = 'XES'
47 = 'MIME'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_Printer | 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.CurrentLanguage
# translate raw value to friendly text:
$friendlyName = $CurrentLanguage_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 "CurrentLanguage" 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 "CurrentLanguage", 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 "CurrentLanguage", 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:
#>
$CurrentLanguage = @{
Name = 'CurrentLanguage'
Expression = {
# property is an array, so process all values
$value = $_.CurrentLanguage
switch([int]$value)
{
1 {'Other'}
2 {'Unknown'}
3 {'PCL'}
4 {'HPGL'}
5 {'PJL'}
6 {'PS'}
7 {'PSPrinter'}
8 {'IPDS'}
9 {'PPDS'}
10 {'EscapeP'}
11 {'Epson'}
12 {'DDIF'}
13 {'Interpress'}
14 {'ISO6429'}
15 {'Line Data'}
16 {'MODCA'}
17 {'REGIS'}
18 {'SCS'}
19 {'SPDL'}
20 {'TEK4014'}
21 {'PDS'}
22 {'IGP'}
23 {'CodeV'}
24 {'DSCDSE'}
25 {'WPS'}
26 {'LN03'}
27 {'CCITT'}
28 {'QUIC'}
29 {'CPAP'}
30 {'DecPPL'}
31 {'Simple Text'}
32 {'NPAP'}
33 {'DOC'}
34 {'imPress'}
35 {'Pinwriter'}
36 {'NPDL'}
37 {'NEC201PL'}
38 {'Automatic'}
39 {'Pages'}
40 {'LIPS'}
41 {'TIFF'}
42 {'Diagnostic'}
43 {'CaPSL'}
44 {'EXCL'}
45 {'LCDS'}
46 {'XES'}
47 {'MIME'}
default {"$value"}
}
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_Printer |
# ...and output properties "Caption" and "CurrentLanguage". The latter is defined
# by the hashtable in $CurrentLanguage:
Select-Object -Property Caption, $CurrentLanguage
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_Printer", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumCurrentLanguage
{
Other = 1
Unknown = 2
PCL = 3
HPGL = 4
PJL = 5
PS = 6
PSPrinter = 7
IPDS = 8
PPDS = 9
EscapeP = 10
Epson = 11
DDIF = 12
Interpress = 13
ISO6429 = 14
Line_Data = 15
MODCA = 16
REGIS = 17
SCS = 18
SPDL = 19
TEK4014 = 20
PDS = 21
IGP = 22
CodeV = 23
DSCDSE = 24
WPS = 25
LN03 = 26
CCITT = 27
QUIC = 28
CPAP = 29
DecPPL = 30
Simple_Text = 31
NPAP = 32
DOC = 33
imPress = 34
Pinwriter = 35
NPDL = 36
NEC201PL = 37
Automatic = 38
Pages = 39
LIPS = 40
TIFF = 41
Diagnostic = 42
CaPSL = 43
EXCL = 44
LCDS = 45
XES = 46
MIME = 47
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_Printer | 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.CurrentLanguage
#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 **CurrentLanguage**
[EnumCurrentLanguage]$rawValue
# get a comma-separated string:
[EnumCurrentLanguage]$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 [EnumCurrentLanguage]
#endregion
Enums must cover all possible values. If CurrentLanguage 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.
CurrentMimeType
MIME type currently being used if the CurrentLanguage is a MIME type (value = 47).
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property CurrentMimeType
CurrentNaturalLanguage
Language that the printer is using for management currently. The language listed here must also be listed in the NaturalLanguagesSupported property.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property CurrentNaturalLanguage
CurrentPaperType
Type of paper the printer is using. Must be expressed in the form specified by the ISO/IEC® 10175 Document Printing Application (DPA), which is summarized in Appendix® C of RFC® 1759 (Printer® MIB).
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property CurrentPaperType
Default
If TRUE, the printer is the default printer.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property Default
DefaultCapabilities
Array of the printer capabilities used by default. Each entry in the DefaultCapabilities array must also be listed in the Capabilities array.
DefaultCapabilities returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$DefaultCapabilities_map = @{
0 = 'Unknown'
1 = 'Other'
2 = 'Color Printing'
3 = 'Duplex Printing'
4 = 'Copies'
5 = 'Collation'
6 = 'Stapling'
7 = 'Transparency Printing'
8 = 'Punch'
9 = 'Cover'
10 = 'Bind'
11 = 'Black and White Printing'
12 = 'One Sided'
13 = 'Two Sided Long Edge'
14 = 'Two Sided Short Edge'
15 = 'Portrait'
16 = 'Landscape'
17 = 'Reverse Portrait'
18 = 'Reverse Landscape'
19 = 'Quality High'
20 = 'Quality Normal'
21 = 'Quality Low'
}
Use a switch statement
switch([int]$value)
{
0 {'Unknown'}
1 {'Other'}
2 {'Color Printing'}
3 {'Duplex Printing'}
4 {'Copies'}
5 {'Collation'}
6 {'Stapling'}
7 {'Transparency Printing'}
8 {'Punch'}
9 {'Cover'}
10 {'Bind'}
11 {'Black and White Printing'}
12 {'One Sided'}
13 {'Two Sided Long Edge'}
14 {'Two Sided Short Edge'}
15 {'Portrait'}
16 {'Landscape'}
17 {'Reverse Portrait'}
18 {'Reverse Landscape'}
19 {'Quality High'}
20 {'Quality Normal'}
21 {'Quality Low'}
default {"$value"}
}
Use Enum structure
Enum EnumDefaultCapabilities
{
Unknown = 0
Other = 1
Color_Printing = 2
Duplex_Printing = 3
Copies = 4
Collation = 5
Stapling = 6
Transparency_Printing = 7
Punch = 8
Cover = 9
Bind = 10
Black_and_White_Printing = 11
One_Sided = 12
Two_Sided_Long_Edge = 13
Two_Sided_Short_Edge = 14
Portrait = 15
Landscape = 16
Reverse_Portrait = 17
Reverse_Landscape = 18
Quality_High = 19
Quality_Normal = 20
Quality_Low = 21
}
Examples
Use $DefaultCapabilities_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "DefaultCapabilities" to friendly text
Note: to use other properties than "DefaultCapabilities", 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 "DefaultCapabilities"
# to translate other properties, use their translation table instead
$DefaultCapabilities_map = @{
0 = 'Unknown'
1 = 'Other'
2 = 'Color Printing'
3 = 'Duplex Printing'
4 = 'Copies'
5 = 'Collation'
6 = 'Stapling'
7 = 'Transparency Printing'
8 = 'Punch'
9 = 'Cover'
10 = 'Bind'
11 = 'Black and White Printing'
12 = 'One Sided'
13 = 'Two Sided Long Edge'
14 = 'Two Sided Short Edge'
15 = 'Portrait'
16 = 'Landscape'
17 = 'Reverse Portrait'
18 = 'Reverse Landscape'
19 = 'Quality High'
20 = 'Quality Normal'
21 = 'Quality Low'
}
#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 "DefaultCapabilities", 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:
#>
$DefaultCapabilities = @{
Name = 'DefaultCapabilities'
Expression = {
# property is an array, so process all values
$result = foreach($value in $_.DefaultCapabilities)
{
# important: convert original value to [int] because
# hashtable keys are type-aware:
$DefaultCapabilities_map[[int]$value]
}
# uncomment to get a comma-separated string instead
# of a string array:
$result <#-join ', '#>
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "DefaultCapabilities". The latter
# is defined by the hashtable in $DefaultCapabilities:
Get-CimInstance -Class Win32_Printer | Select-Object -Property Caption, $DefaultCapabilities
# ...or dump content of property DefaultCapabilities:
$friendlyValues = Get-CimInstance -Class Win32_Printer |
Select-Object -Property $DefaultCapabilities |
Select-Object -ExpandProperty DefaultCapabilities
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $DefaultCapabilities_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_Printer" to friendly text. This approach is ideal when there
is just one instance to work with.
Note: to use other properties than "Win32_Printer", 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_Printer"
# to translate other properties, use their translation table instead
$DefaultCapabilities_map = @{
0 = 'Unknown'
1 = 'Other'
2 = 'Color Printing'
3 = 'Duplex Printing'
4 = 'Copies'
5 = 'Collation'
6 = 'Stapling'
7 = 'Transparency Printing'
8 = 'Punch'
9 = 'Cover'
10 = 'Bind'
11 = 'Black and White Printing'
12 = 'One Sided'
13 = 'Two Sided Long Edge'
14 = 'Two Sided Short Edge'
15 = 'Portrait'
16 = 'Landscape'
17 = 'Reverse Portrait'
18 = 'Reverse Landscape'
19 = 'Quality High'
20 = 'Quality Normal'
21 = 'Quality Low'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_Printer | 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 (hint: the property is an array!)
$rawValues = $instance.DefaultCapabilities
# translate all raw values into friendly names:
$friendlyNames = foreach($rawValue in $rawValues)
{ $DefaultCapabilities_map[[int]$rawValue] }
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use a switch statement inside a calculated property for Select-Object
<#
this example uses a switch clause to translate raw numeric
values for property "DefaultCapabilities" 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 "DefaultCapabilities", 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 "DefaultCapabilities", 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:
#>
$DefaultCapabilities = @{
Name = 'DefaultCapabilities'
Expression = {
# property is an array, so process all values
$result = foreach($value in $_.DefaultCapabilities)
{
switch([int]$value)
{
0 {'Unknown'}
1 {'Other'}
2 {'Color Printing'}
3 {'Duplex Printing'}
4 {'Copies'}
5 {'Collation'}
6 {'Stapling'}
7 {'Transparency Printing'}
8 {'Punch'}
9 {'Cover'}
10 {'Bind'}
11 {'Black and White Printing'}
12 {'One Sided'}
13 {'Two Sided Long Edge'}
14 {'Two Sided Short Edge'}
15 {'Portrait'}
16 {'Landscape'}
17 {'Reverse Portrait'}
18 {'Reverse Landscape'}
19 {'Quality High'}
20 {'Quality Normal'}
21 {'Quality Low'}
default {"$value"}
}
}
$result
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_Printer |
# ...and output properties "Caption" and "DefaultCapabilities". The latter is defined
# by the hashtable in $DefaultCapabilities:
Select-Object -Property Caption, $DefaultCapabilities
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_Printer", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumDefaultCapabilities
{
Unknown = 0
Other = 1
Color_Printing = 2
Duplex_Printing = 3
Copies = 4
Collation = 5
Stapling = 6
Transparency_Printing = 7
Punch = 8
Cover = 9
Bind = 10
Black_and_White_Printing = 11
One_Sided = 12
Two_Sided_Long_Edge = 13
Two_Sided_Short_Edge = 14
Portrait = 15
Landscape = 16
Reverse_Portrait = 17
Reverse_Landscape = 18
Quality_High = 19
Quality_Normal = 20
Quality_Low = 21
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_Printer | 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.DefaultCapabilities
#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 **DefaultCapabilities**
[EnumDefaultCapabilities[]]$rawValue
# get a comma-separated string:
[EnumDefaultCapabilities[]]$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 [EnumDefaultCapabilities[]]
#endregion
Enums must cover all possible values. If DefaultCapabilities 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.
DefaultCopies
Number of copies produced for one jobâunless otherwise specified.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property DefaultCopies
DefaultLanguage
Default printer language. The language listed here must also be listed in the LanguagesSupported property.
DefaultLanguage returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$DefaultLanguage_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'PCL'
4 = 'HPGL'
5 = 'PJL'
6 = 'PS'
7 = 'PSPrinter'
8 = 'IPDS'
9 = 'PPDS'
10 = 'EscapeP'
11 = 'Epson'
12 = 'DDIF'
13 = 'Interpress'
14 = 'ISO6429'
15 = 'Line Data'
16 = 'MODCA'
17 = 'REGIS'
18 = 'SCS'
19 = 'SPDL'
20 = 'TEK4014'
21 = 'PDS'
22 = 'IGP'
23 = 'CodeV'
24 = 'DSCDSE'
25 = 'WPS'
26 = 'LN03'
27 = 'CCITT'
28 = 'QUIC'
29 = 'CPAP'
30 = 'DecPPL'
31 = 'Simple Text'
32 = 'NPAP'
33 = 'DOC'
34 = 'imPress'
35 = 'Pinwriter'
36 = 'NPDL'
37 = 'NEC201PL'
38 = 'Automatic'
39 = 'Pages'
40 = 'LIPS'
41 = 'TIFF'
42 = 'Diagnostic'
43 = 'CaPSL'
44 = 'EXCL'
45 = 'LCDS'
46 = 'XES'
47 = 'MIME'
}
Use a switch statement
switch([int]$value)
{
1 {'Other'}
2 {'Unknown'}
3 {'PCL'}
4 {'HPGL'}
5 {'PJL'}
6 {'PS'}
7 {'PSPrinter'}
8 {'IPDS'}
9 {'PPDS'}
10 {'EscapeP'}
11 {'Epson'}
12 {'DDIF'}
13 {'Interpress'}
14 {'ISO6429'}
15 {'Line Data'}
16 {'MODCA'}
17 {'REGIS'}
18 {'SCS'}
19 {'SPDL'}
20 {'TEK4014'}
21 {'PDS'}
22 {'IGP'}
23 {'CodeV'}
24 {'DSCDSE'}
25 {'WPS'}
26 {'LN03'}
27 {'CCITT'}
28 {'QUIC'}
29 {'CPAP'}
30 {'DecPPL'}
31 {'Simple Text'}
32 {'NPAP'}
33 {'DOC'}
34 {'imPress'}
35 {'Pinwriter'}
36 {'NPDL'}
37 {'NEC201PL'}
38 {'Automatic'}
39 {'Pages'}
40 {'LIPS'}
41 {'TIFF'}
42 {'Diagnostic'}
43 {'CaPSL'}
44 {'EXCL'}
45 {'LCDS'}
46 {'XES'}
47 {'MIME'}
default {"$value"}
}
Use Enum structure
Enum EnumDefaultLanguage
{
Other = 1
Unknown = 2
PCL = 3
HPGL = 4
PJL = 5
PS = 6
PSPrinter = 7
IPDS = 8
PPDS = 9
EscapeP = 10
Epson = 11
DDIF = 12
Interpress = 13
ISO6429 = 14
Line_Data = 15
MODCA = 16
REGIS = 17
SCS = 18
SPDL = 19
TEK4014 = 20
PDS = 21
IGP = 22
CodeV = 23
DSCDSE = 24
WPS = 25
LN03 = 26
CCITT = 27
QUIC = 28
CPAP = 29
DecPPL = 30
Simple_Text = 31
NPAP = 32
DOC = 33
imPress = 34
Pinwriter = 35
NPDL = 36
NEC201PL = 37
Automatic = 38
Pages = 39
LIPS = 40
TIFF = 41
Diagnostic = 42
CaPSL = 43
EXCL = 44
LCDS = 45
XES = 46
MIME = 47
}
Examples
Use $DefaultLanguage_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "DefaultLanguage" to friendly text
Note: to use other properties than "DefaultLanguage", 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 "DefaultLanguage"
# to translate other properties, use their translation table instead
$DefaultLanguage_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'PCL'
4 = 'HPGL'
5 = 'PJL'
6 = 'PS'
7 = 'PSPrinter'
8 = 'IPDS'
9 = 'PPDS'
10 = 'EscapeP'
11 = 'Epson'
12 = 'DDIF'
13 = 'Interpress'
14 = 'ISO6429'
15 = 'Line Data'
16 = 'MODCA'
17 = 'REGIS'
18 = 'SCS'
19 = 'SPDL'
20 = 'TEK4014'
21 = 'PDS'
22 = 'IGP'
23 = 'CodeV'
24 = 'DSCDSE'
25 = 'WPS'
26 = 'LN03'
27 = 'CCITT'
28 = 'QUIC'
29 = 'CPAP'
30 = 'DecPPL'
31 = 'Simple Text'
32 = 'NPAP'
33 = 'DOC'
34 = 'imPress'
35 = 'Pinwriter'
36 = 'NPDL'
37 = 'NEC201PL'
38 = 'Automatic'
39 = 'Pages'
40 = 'LIPS'
41 = 'TIFF'
42 = 'Diagnostic'
43 = 'CaPSL'
44 = 'EXCL'
45 = 'LCDS'
46 = 'XES'
47 = 'MIME'
}
#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 "DefaultLanguage", 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:
#>
$DefaultLanguage = @{
Name = 'DefaultLanguage'
Expression = {
# property is an array, so process all values
$value = $_.DefaultLanguage
$DefaultLanguage_map[[int]$value]
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "DefaultLanguage". The latter
# is defined by the hashtable in $DefaultLanguage:
Get-CimInstance -Class Win32_Printer | Select-Object -Property Caption, $DefaultLanguage
# ...or dump content of property DefaultLanguage:
$friendlyValues = Get-CimInstance -Class Win32_Printer |
Select-Object -Property $DefaultLanguage |
Select-Object -ExpandProperty DefaultLanguage
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $DefaultLanguage_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_Printer" to friendly text. This approach is ideal when
there is just one instance to work with.
Note: to use other properties than "Win32_Printer", 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_Printer"
# to translate other properties, use their translation table instead
$DefaultLanguage_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'PCL'
4 = 'HPGL'
5 = 'PJL'
6 = 'PS'
7 = 'PSPrinter'
8 = 'IPDS'
9 = 'PPDS'
10 = 'EscapeP'
11 = 'Epson'
12 = 'DDIF'
13 = 'Interpress'
14 = 'ISO6429'
15 = 'Line Data'
16 = 'MODCA'
17 = 'REGIS'
18 = 'SCS'
19 = 'SPDL'
20 = 'TEK4014'
21 = 'PDS'
22 = 'IGP'
23 = 'CodeV'
24 = 'DSCDSE'
25 = 'WPS'
26 = 'LN03'
27 = 'CCITT'
28 = 'QUIC'
29 = 'CPAP'
30 = 'DecPPL'
31 = 'Simple Text'
32 = 'NPAP'
33 = 'DOC'
34 = 'imPress'
35 = 'Pinwriter'
36 = 'NPDL'
37 = 'NEC201PL'
38 = 'Automatic'
39 = 'Pages'
40 = 'LIPS'
41 = 'TIFF'
42 = 'Diagnostic'
43 = 'CaPSL'
44 = 'EXCL'
45 = 'LCDS'
46 = 'XES'
47 = 'MIME'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_Printer | 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.DefaultLanguage
# translate raw value to friendly text:
$friendlyName = $DefaultLanguage_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 "DefaultLanguage" 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 "DefaultLanguage", 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 "DefaultLanguage", 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:
#>
$DefaultLanguage = @{
Name = 'DefaultLanguage'
Expression = {
# property is an array, so process all values
$value = $_.DefaultLanguage
switch([int]$value)
{
1 {'Other'}
2 {'Unknown'}
3 {'PCL'}
4 {'HPGL'}
5 {'PJL'}
6 {'PS'}
7 {'PSPrinter'}
8 {'IPDS'}
9 {'PPDS'}
10 {'EscapeP'}
11 {'Epson'}
12 {'DDIF'}
13 {'Interpress'}
14 {'ISO6429'}
15 {'Line Data'}
16 {'MODCA'}
17 {'REGIS'}
18 {'SCS'}
19 {'SPDL'}
20 {'TEK4014'}
21 {'PDS'}
22 {'IGP'}
23 {'CodeV'}
24 {'DSCDSE'}
25 {'WPS'}
26 {'LN03'}
27 {'CCITT'}
28 {'QUIC'}
29 {'CPAP'}
30 {'DecPPL'}
31 {'Simple Text'}
32 {'NPAP'}
33 {'DOC'}
34 {'imPress'}
35 {'Pinwriter'}
36 {'NPDL'}
37 {'NEC201PL'}
38 {'Automatic'}
39 {'Pages'}
40 {'LIPS'}
41 {'TIFF'}
42 {'Diagnostic'}
43 {'CaPSL'}
44 {'EXCL'}
45 {'LCDS'}
46 {'XES'}
47 {'MIME'}
default {"$value"}
}
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_Printer |
# ...and output properties "Caption" and "DefaultLanguage". The latter is defined
# by the hashtable in $DefaultLanguage:
Select-Object -Property Caption, $DefaultLanguage
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_Printer", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumDefaultLanguage
{
Other = 1
Unknown = 2
PCL = 3
HPGL = 4
PJL = 5
PS = 6
PSPrinter = 7
IPDS = 8
PPDS = 9
EscapeP = 10
Epson = 11
DDIF = 12
Interpress = 13
ISO6429 = 14
Line_Data = 15
MODCA = 16
REGIS = 17
SCS = 18
SPDL = 19
TEK4014 = 20
PDS = 21
IGP = 22
CodeV = 23
DSCDSE = 24
WPS = 25
LN03 = 26
CCITT = 27
QUIC = 28
CPAP = 29
DecPPL = 30
Simple_Text = 31
NPAP = 32
DOC = 33
imPress = 34
Pinwriter = 35
NPDL = 36
NEC201PL = 37
Automatic = 38
Pages = 39
LIPS = 40
TIFF = 41
Diagnostic = 42
CaPSL = 43
EXCL = 44
LCDS = 45
XES = 46
MIME = 47
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_Printer | 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.DefaultLanguage
#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 **DefaultLanguage**
[EnumDefaultLanguage]$rawValue
# get a comma-separated string:
[EnumDefaultLanguage]$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 [EnumDefaultLanguage]
#endregion
Enums must cover all possible values. If DefaultLanguage 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.
DefaultMimeType
MIME type currently being used, if the DefaultLanguage value is a MIME type (value = 47).
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property DefaultMimeType
DefaultNumberUp
Number of print-stream pages that the printer renders on one media sheetâunless a job specifies otherwise.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property DefaultNumberUp
DefaultPaperType
Paper type that the printer usesâunless a print job specifies a different paper type. The string must be expressed in the form specified by ISO/IEC® 1017 Document Printing Application (DPA), which is summarized in Appendix® C of RFC® 1759 (Printer MIB).
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property DefaultPaperType
DefaultPriority
Default priority value assigned to each print job.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property DefaultPriority
Description
Description of an object.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property Description
DetectedErrorState
Printer error information.
DetectedErrorState returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$DetectedErrorState_map = @{
0 = 'Unknown'
1 = 'Other'
2 = 'No Error'
3 = 'Low Paper'
4 = 'No Paper'
5 = 'Low Toner'
6 = 'No Toner'
7 = 'Door Open'
8 = 'Jammed'
9 = 'Offline'
10 = 'Service Requested'
11 = 'Output Bin Full'
}
Use a switch statement
switch([int]$value)
{
0 {'Unknown'}
1 {'Other'}
2 {'No Error'}
3 {'Low Paper'}
4 {'No Paper'}
5 {'Low Toner'}
6 {'No Toner'}
7 {'Door Open'}
8 {'Jammed'}
9 {'Offline'}
10 {'Service Requested'}
11 {'Output Bin Full'}
default {"$value"}
}
Use Enum structure
Enum EnumDetectedErrorState
{
Unknown = 0
Other = 1
No_Error = 2
Low_Paper = 3
No_Paper = 4
Low_Toner = 5
No_Toner = 6
Door_Open = 7
Jammed = 8
Offline = 9
Service_Requested = 10
Output_Bin_Full = 11
}
Examples
Use $DetectedErrorState_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "DetectedErrorState" to friendly text
Note: to use other properties than "DetectedErrorState", 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 "DetectedErrorState"
# to translate other properties, use their translation table instead
$DetectedErrorState_map = @{
0 = 'Unknown'
1 = 'Other'
2 = 'No Error'
3 = 'Low Paper'
4 = 'No Paper'
5 = 'Low Toner'
6 = 'No Toner'
7 = 'Door Open'
8 = 'Jammed'
9 = 'Offline'
10 = 'Service Requested'
11 = 'Output Bin Full'
}
#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 "DetectedErrorState", 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:
#>
$DetectedErrorState = @{
Name = 'DetectedErrorState'
Expression = {
# property is an array, so process all values
$value = $_.DetectedErrorState
$DetectedErrorState_map[[int]$value]
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "DetectedErrorState". The latter
# is defined by the hashtable in $DetectedErrorState:
Get-CimInstance -Class Win32_Printer | Select-Object -Property Caption, $DetectedErrorState
# ...or dump content of property DetectedErrorState:
$friendlyValues = Get-CimInstance -Class Win32_Printer |
Select-Object -Property $DetectedErrorState |
Select-Object -ExpandProperty DetectedErrorState
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $DetectedErrorState_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_Printer" to friendly text. This approach is ideal when
there is just one instance to work with.
Note: to use other properties than "Win32_Printer", 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_Printer"
# to translate other properties, use their translation table instead
$DetectedErrorState_map = @{
0 = 'Unknown'
1 = 'Other'
2 = 'No Error'
3 = 'Low Paper'
4 = 'No Paper'
5 = 'Low Toner'
6 = 'No Toner'
7 = 'Door Open'
8 = 'Jammed'
9 = 'Offline'
10 = 'Service Requested'
11 = 'Output Bin Full'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_Printer | 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.DetectedErrorState
# translate raw value to friendly text:
$friendlyName = $DetectedErrorState_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 "DetectedErrorState" 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 "DetectedErrorState", 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 "DetectedErrorState", 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:
#>
$DetectedErrorState = @{
Name = 'DetectedErrorState'
Expression = {
# property is an array, so process all values
$value = $_.DetectedErrorState
switch([int]$value)
{
0 {'Unknown'}
1 {'Other'}
2 {'No Error'}
3 {'Low Paper'}
4 {'No Paper'}
5 {'Low Toner'}
6 {'No Toner'}
7 {'Door Open'}
8 {'Jammed'}
9 {'Offline'}
10 {'Service Requested'}
11 {'Output Bin Full'}
default {"$value"}
}
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_Printer |
# ...and output properties "Caption" and "DetectedErrorState". The latter is defined
# by the hashtable in $DetectedErrorState:
Select-Object -Property Caption, $DetectedErrorState
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_Printer", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumDetectedErrorState
{
Unknown = 0
Other = 1
No_Error = 2
Low_Paper = 3
No_Paper = 4
Low_Toner = 5
No_Toner = 6
Door_Open = 7
Jammed = 8
Offline = 9
Service_Requested = 10
Output_Bin_Full = 11
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_Printer | 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.DetectedErrorState
#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 **DetectedErrorState**
[EnumDetectedErrorState]$rawValue
# get a comma-separated string:
[EnumDetectedErrorState]$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 [EnumDetectedErrorState]
#endregion
Enums must cover all possible values. If DetectedErrorState 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.
DeviceID
Unique identifier of the printer on a system.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property DeviceID
Direct
If TRUE, the print job is sent directly to the printer. If FALSE, the print job is spooled.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property Direct
DoCompleteFirst
If TRUE, the printer starts jobs that are finished spooling. If FALSE, the printer starts jobs in the order that the jobs are received.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property DoCompleteFirst
DriverName
Name of the Windows printer driver.
Example: Windows Fax Driver
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property DriverName
EnableBIDI
If TRUE, the printer can print bidirectionally.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property EnableBIDI
EnableDevQueryPrint
If TRUE, the printer holds documents in the queue when document and printer setups do not match.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property EnableDevQueryPrint
ErrorCleared
If TRUE, the error reported in LastErrorCode has been cleared.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property ErrorCleared
ErrorDescription
Information about the error recorded in LastErrorCode, and information about corrective actions that can be taken.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property ErrorDescription
ErrorInformation
Array of supplemental information for the current error state indicated in DetectedErrorState.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property ErrorInformation
ExtendedDetectedErrorState
Reports standard error information. Additional information should be recorded in DetectedErrorState.
Values are:
0 (0x0)
Unknown
1 (0x1)
Other
2 (0x2)
No Error
3 (0x3)
Low Paper
4 (0x4)
No Paper
5 (0x5)
Low Toner
6 (0x6)
No Toner
7 (0x7)
Door Open
8 (0x8)
Jammed
9 (0x9)
Service Requested
10 (0xA)
Output Bin Full
11 (0xB)
Paper Problem
12 (0xC)
Cannot Print Page
13 (0xD)
User Intervention Required
14 (0xE)
Out of Memory
15 (0xF)
Server Unknown
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property ExtendedDetectedErrorState
ExtendedPrinterStatus
Status information for a printer that is different from information specified in the Availability property.
1 (0x1)
Other
2 (0x2)
Unknown
3 (0x3)
Idle
4 (0x4)
Printing
5 (0x5)
Warming Up
6 (0x6)
Stopped Printing
7
Offline
8 (0x8)
Paused
9 (0x9)
Error
10 (0xA)
Busy
11 (0xB)
Not Available
12 (0xC)
Waiting
13 (0xD)
Processing
14 (0xE)
Initialization
15
Power Save
16 (0x10)
Pending Deletion
17 (0x11)
I/O Active
18 (0x12)
Manual Feed
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property ExtendedPrinterStatus
Hidden
If TRUE, the printer is hidden from network users.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property Hidden
HorizontalResolution
Horizontal resolution of the printerâin pixels per inch.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property HorizontalResolution
InstallDate
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property InstallDate
JobCountSinceLastReset
Number of print jobs since the printer was last reset.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property JobCountSinceLastReset
KeepPrintedJobs
If TRUE, the print spooler does not delete the completed jobs.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property KeepPrintedJobs
LanguagesSupported
Array of the print languages natively supported.
LanguagesSupported returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$LanguagesSupported_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'PCL'
4 = 'HPGL'
5 = 'PJL'
6 = 'PS'
7 = 'PSPrinter'
8 = 'IPDS'
9 = 'PPDS'
10 = 'EscapeP'
11 = 'Epson'
12 = 'DDIF'
13 = 'Interpress'
14 = 'ISO6429'
15 = 'Line Data'
16 = 'MODCA'
17 = 'REGIS'
18 = 'SCS'
19 = 'SPDL'
20 = 'TEK4014'
21 = 'PDS'
22 = 'IGP'
23 = 'CodeV'
24 = 'DSCDSE'
25 = 'WPS'
26 = 'LN03'
27 = 'CCITT'
28 = 'QUIC'
29 = 'CPAP'
30 = 'DecPPL'
31 = 'Simple Text'
32 = 'NPAP'
33 = 'DOC'
34 = 'imPress'
35 = 'Pinwriter'
36 = 'NPDL'
37 = 'NEC201PL'
38 = 'Automatic'
39 = 'Pages'
40 = 'LIPS'
41 = 'TIFF'
42 = 'Diagnostic'
43 = 'CaPSL'
44 = 'EXCL'
45 = 'LCDS'
46 = 'XES'
47 = 'MIME'
48 = 'XPS'
49 = 'HPGL2'
50 = 'PCLXL'
}
Use a switch statement
switch([int]$value)
{
1 {'Other'}
2 {'Unknown'}
3 {'PCL'}
4 {'HPGL'}
5 {'PJL'}
6 {'PS'}
7 {'PSPrinter'}
8 {'IPDS'}
9 {'PPDS'}
10 {'EscapeP'}
11 {'Epson'}
12 {'DDIF'}
13 {'Interpress'}
14 {'ISO6429'}
15 {'Line Data'}
16 {'MODCA'}
17 {'REGIS'}
18 {'SCS'}
19 {'SPDL'}
20 {'TEK4014'}
21 {'PDS'}
22 {'IGP'}
23 {'CodeV'}
24 {'DSCDSE'}
25 {'WPS'}
26 {'LN03'}
27 {'CCITT'}
28 {'QUIC'}
29 {'CPAP'}
30 {'DecPPL'}
31 {'Simple Text'}
32 {'NPAP'}
33 {'DOC'}
34 {'imPress'}
35 {'Pinwriter'}
36 {'NPDL'}
37 {'NEC201PL'}
38 {'Automatic'}
39 {'Pages'}
40 {'LIPS'}
41 {'TIFF'}
42 {'Diagnostic'}
43 {'CaPSL'}
44 {'EXCL'}
45 {'LCDS'}
46 {'XES'}
47 {'MIME'}
48 {'XPS'}
49 {'HPGL2'}
50 {'PCLXL'}
default {"$value"}
}
Use Enum structure
Enum EnumLanguagesSupported
{
Other = 1
Unknown = 2
PCL = 3
HPGL = 4
PJL = 5
PS = 6
PSPrinter = 7
IPDS = 8
PPDS = 9
EscapeP = 10
Epson = 11
DDIF = 12
Interpress = 13
ISO6429 = 14
Line_Data = 15
MODCA = 16
REGIS = 17
SCS = 18
SPDL = 19
TEK4014 = 20
PDS = 21
IGP = 22
CodeV = 23
DSCDSE = 24
WPS = 25
LN03 = 26
CCITT = 27
QUIC = 28
CPAP = 29
DecPPL = 30
Simple_Text = 31
NPAP = 32
DOC = 33
imPress = 34
Pinwriter = 35
NPDL = 36
NEC201PL = 37
Automatic = 38
Pages = 39
LIPS = 40
TIFF = 41
Diagnostic = 42
CaPSL = 43
EXCL = 44
LCDS = 45
XES = 46
MIME = 47
XPS = 48
HPGL2 = 49
PCLXL = 50
}
Examples
Use $LanguagesSupported_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "LanguagesSupported" to friendly text
Note: to use other properties than "LanguagesSupported", 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 "LanguagesSupported"
# to translate other properties, use their translation table instead
$LanguagesSupported_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'PCL'
4 = 'HPGL'
5 = 'PJL'
6 = 'PS'
7 = 'PSPrinter'
8 = 'IPDS'
9 = 'PPDS'
10 = 'EscapeP'
11 = 'Epson'
12 = 'DDIF'
13 = 'Interpress'
14 = 'ISO6429'
15 = 'Line Data'
16 = 'MODCA'
17 = 'REGIS'
18 = 'SCS'
19 = 'SPDL'
20 = 'TEK4014'
21 = 'PDS'
22 = 'IGP'
23 = 'CodeV'
24 = 'DSCDSE'
25 = 'WPS'
26 = 'LN03'
27 = 'CCITT'
28 = 'QUIC'
29 = 'CPAP'
30 = 'DecPPL'
31 = 'Simple Text'
32 = 'NPAP'
33 = 'DOC'
34 = 'imPress'
35 = 'Pinwriter'
36 = 'NPDL'
37 = 'NEC201PL'
38 = 'Automatic'
39 = 'Pages'
40 = 'LIPS'
41 = 'TIFF'
42 = 'Diagnostic'
43 = 'CaPSL'
44 = 'EXCL'
45 = 'LCDS'
46 = 'XES'
47 = 'MIME'
48 = 'XPS'
49 = 'HPGL2'
50 = 'PCLXL'
}
#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 "LanguagesSupported", 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:
#>
$LanguagesSupported = @{
Name = 'LanguagesSupported'
Expression = {
# property is an array, so process all values
$result = foreach($value in $_.LanguagesSupported)
{
# important: convert original value to [int] because
# hashtable keys are type-aware:
$LanguagesSupported_map[[int]$value]
}
# uncomment to get a comma-separated string instead
# of a string array:
$result <#-join ', '#>
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "LanguagesSupported". The latter
# is defined by the hashtable in $LanguagesSupported:
Get-CimInstance -Class Win32_Printer | Select-Object -Property Caption, $LanguagesSupported
# ...or dump content of property LanguagesSupported:
$friendlyValues = Get-CimInstance -Class Win32_Printer |
Select-Object -Property $LanguagesSupported |
Select-Object -ExpandProperty LanguagesSupported
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $LanguagesSupported_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_Printer" to friendly text. This approach is ideal when there
is just one instance to work with.
Note: to use other properties than "Win32_Printer", 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_Printer"
# to translate other properties, use their translation table instead
$LanguagesSupported_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'PCL'
4 = 'HPGL'
5 = 'PJL'
6 = 'PS'
7 = 'PSPrinter'
8 = 'IPDS'
9 = 'PPDS'
10 = 'EscapeP'
11 = 'Epson'
12 = 'DDIF'
13 = 'Interpress'
14 = 'ISO6429'
15 = 'Line Data'
16 = 'MODCA'
17 = 'REGIS'
18 = 'SCS'
19 = 'SPDL'
20 = 'TEK4014'
21 = 'PDS'
22 = 'IGP'
23 = 'CodeV'
24 = 'DSCDSE'
25 = 'WPS'
26 = 'LN03'
27 = 'CCITT'
28 = 'QUIC'
29 = 'CPAP'
30 = 'DecPPL'
31 = 'Simple Text'
32 = 'NPAP'
33 = 'DOC'
34 = 'imPress'
35 = 'Pinwriter'
36 = 'NPDL'
37 = 'NEC201PL'
38 = 'Automatic'
39 = 'Pages'
40 = 'LIPS'
41 = 'TIFF'
42 = 'Diagnostic'
43 = 'CaPSL'
44 = 'EXCL'
45 = 'LCDS'
46 = 'XES'
47 = 'MIME'
48 = 'XPS'
49 = 'HPGL2'
50 = 'PCLXL'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_Printer | 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 (hint: the property is an array!)
$rawValues = $instance.LanguagesSupported
# translate all raw values into friendly names:
$friendlyNames = foreach($rawValue in $rawValues)
{ $LanguagesSupported_map[[int]$rawValue] }
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use a switch statement inside a calculated property for Select-Object
<#
this example uses a switch clause to translate raw numeric
values for property "LanguagesSupported" 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 "LanguagesSupported", 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 "LanguagesSupported", 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:
#>
$LanguagesSupported = @{
Name = 'LanguagesSupported'
Expression = {
# property is an array, so process all values
$result = foreach($value in $_.LanguagesSupported)
{
switch([int]$value)
{
1 {'Other'}
2 {'Unknown'}
3 {'PCL'}
4 {'HPGL'}
5 {'PJL'}
6 {'PS'}
7 {'PSPrinter'}
8 {'IPDS'}
9 {'PPDS'}
10 {'EscapeP'}
11 {'Epson'}
12 {'DDIF'}
13 {'Interpress'}
14 {'ISO6429'}
15 {'Line Data'}
16 {'MODCA'}
17 {'REGIS'}
18 {'SCS'}
19 {'SPDL'}
20 {'TEK4014'}
21 {'PDS'}
22 {'IGP'}
23 {'CodeV'}
24 {'DSCDSE'}
25 {'WPS'}
26 {'LN03'}
27 {'CCITT'}
28 {'QUIC'}
29 {'CPAP'}
30 {'DecPPL'}
31 {'Simple Text'}
32 {'NPAP'}
33 {'DOC'}
34 {'imPress'}
35 {'Pinwriter'}
36 {'NPDL'}
37 {'NEC201PL'}
38 {'Automatic'}
39 {'Pages'}
40 {'LIPS'}
41 {'TIFF'}
42 {'Diagnostic'}
43 {'CaPSL'}
44 {'EXCL'}
45 {'LCDS'}
46 {'XES'}
47 {'MIME'}
48 {'XPS'}
49 {'HPGL2'}
50 {'PCLXL'}
default {"$value"}
}
}
$result
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_Printer |
# ...and output properties "Caption" and "LanguagesSupported". The latter is defined
# by the hashtable in $LanguagesSupported:
Select-Object -Property Caption, $LanguagesSupported
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_Printer", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumLanguagesSupported
{
Other = 1
Unknown = 2
PCL = 3
HPGL = 4
PJL = 5
PS = 6
PSPrinter = 7
IPDS = 8
PPDS = 9
EscapeP = 10
Epson = 11
DDIF = 12
Interpress = 13
ISO6429 = 14
Line_Data = 15
MODCA = 16
REGIS = 17
SCS = 18
SPDL = 19
TEK4014 = 20
PDS = 21
IGP = 22
CodeV = 23
DSCDSE = 24
WPS = 25
LN03 = 26
CCITT = 27
QUIC = 28
CPAP = 29
DecPPL = 30
Simple_Text = 31
NPAP = 32
DOC = 33
imPress = 34
Pinwriter = 35
NPDL = 36
NEC201PL = 37
Automatic = 38
Pages = 39
LIPS = 40
TIFF = 41
Diagnostic = 42
CaPSL = 43
EXCL = 44
LCDS = 45
XES = 46
MIME = 47
XPS = 48
HPGL2 = 49
PCLXL = 50
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_Printer | 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.LanguagesSupported
#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 **LanguagesSupported**
[EnumLanguagesSupported[]]$rawValue
# get a comma-separated string:
[EnumLanguagesSupported[]]$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 [EnumLanguagesSupported[]]
#endregion
Enums must cover all possible values. If LanguagesSupported 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.
LastErrorCode
Last error code that the logical device reports.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property LastErrorCode
Local
If TRUE, the printer is not attached to a network. If both the Local and Network properties are set to TRUE, then the printer is a network printer.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property Local
Location
Physical location of the printer.
Example: Bldg. 38, Room 1164
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property Location
MarkingTechnology
Marking technology the printer uses.
MarkingTechnology returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$MarkingTechnology_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Electrophotographic LED'
4 = 'Electrophotographic Laser'
5 = 'Electrophotographic Other'
6 = 'Impact Moving Head Dot Matrix 9pin'
7 = 'Impact Moving Head Dot Matrix 24pin'
8 = 'Impact Moving Head Dot Matrix Other'
9 = 'Impact Moving Head Fully Formed'
10 = 'Impact Band'
11 = 'Impact Other'
12 = 'Inkjet Aqueous'
13 = 'Inkjet Solid'
14 = 'Inkjet Other'
15 = 'Pen'
16 = 'Thermal Transfer'
17 = 'Thermal Sensitive'
18 = 'Thermal Diffusion'
19 = 'Thermal Other'
20 = 'Electroerosion'
21 = 'Electrostatic'
22 = 'Photographic Microfiche'
23 = 'Photographic Imagesetter'
24 = 'Photographic Other'
25 = 'Ion Deposition'
26 = 'eBeam'
27 = 'Typesetter'
}
Use a switch statement
switch([int]$value)
{
1 {'Other'}
2 {'Unknown'}
3 {'Electrophotographic LED'}
4 {'Electrophotographic Laser'}
5 {'Electrophotographic Other'}
6 {'Impact Moving Head Dot Matrix 9pin'}
7 {'Impact Moving Head Dot Matrix 24pin'}
8 {'Impact Moving Head Dot Matrix Other'}
9 {'Impact Moving Head Fully Formed'}
10 {'Impact Band'}
11 {'Impact Other'}
12 {'Inkjet Aqueous'}
13 {'Inkjet Solid'}
14 {'Inkjet Other'}
15 {'Pen'}
16 {'Thermal Transfer'}
17 {'Thermal Sensitive'}
18 {'Thermal Diffusion'}
19 {'Thermal Other'}
20 {'Electroerosion'}
21 {'Electrostatic'}
22 {'Photographic Microfiche'}
23 {'Photographic Imagesetter'}
24 {'Photographic Other'}
25 {'Ion Deposition'}
26 {'eBeam'}
27 {'Typesetter'}
default {"$value"}
}
Use Enum structure
Enum EnumMarkingTechnology
{
Other = 1
Unknown = 2
Electrophotographic_LED = 3
Electrophotographic_Laser = 4
Electrophotographic_Other = 5
Impact_Moving_Head_Dot_Matrix_9pin = 6
Impact_Moving_Head_Dot_Matrix_24pin = 7
Impact_Moving_Head_Dot_Matrix_Other = 8
Impact_Moving_Head_Fully_Formed = 9
Impact_Band = 10
Impact_Other = 11
Inkjet_Aqueous = 12
Inkjet_Solid = 13
Inkjet_Other = 14
Pen = 15
Thermal_Transfer = 16
Thermal_Sensitive = 17
Thermal_Diffusion = 18
Thermal_Other = 19
Electroerosion = 20
Electrostatic = 21
Photographic_Microfiche = 22
Photographic_Imagesetter = 23
Photographic_Other = 24
Ion_Deposition = 25
eBeam = 26
Typesetter = 27
}
Examples
Use $MarkingTechnology_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "MarkingTechnology" to friendly text
Note: to use other properties than "MarkingTechnology", 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 "MarkingTechnology"
# to translate other properties, use their translation table instead
$MarkingTechnology_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Electrophotographic LED'
4 = 'Electrophotographic Laser'
5 = 'Electrophotographic Other'
6 = 'Impact Moving Head Dot Matrix 9pin'
7 = 'Impact Moving Head Dot Matrix 24pin'
8 = 'Impact Moving Head Dot Matrix Other'
9 = 'Impact Moving Head Fully Formed'
10 = 'Impact Band'
11 = 'Impact Other'
12 = 'Inkjet Aqueous'
13 = 'Inkjet Solid'
14 = 'Inkjet Other'
15 = 'Pen'
16 = 'Thermal Transfer'
17 = 'Thermal Sensitive'
18 = 'Thermal Diffusion'
19 = 'Thermal Other'
20 = 'Electroerosion'
21 = 'Electrostatic'
22 = 'Photographic Microfiche'
23 = 'Photographic Imagesetter'
24 = 'Photographic Other'
25 = 'Ion Deposition'
26 = 'eBeam'
27 = 'Typesetter'
}
#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 "MarkingTechnology", 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:
#>
$MarkingTechnology = @{
Name = 'MarkingTechnology'
Expression = {
# property is an array, so process all values
$value = $_.MarkingTechnology
$MarkingTechnology_map[[int]$value]
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "MarkingTechnology". The latter
# is defined by the hashtable in $MarkingTechnology:
Get-CimInstance -Class Win32_Printer | Select-Object -Property Caption, $MarkingTechnology
# ...or dump content of property MarkingTechnology:
$friendlyValues = Get-CimInstance -Class Win32_Printer |
Select-Object -Property $MarkingTechnology |
Select-Object -ExpandProperty MarkingTechnology
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $MarkingTechnology_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_Printer" to friendly text. This approach is ideal when
there is just one instance to work with.
Note: to use other properties than "Win32_Printer", 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_Printer"
# to translate other properties, use their translation table instead
$MarkingTechnology_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Electrophotographic LED'
4 = 'Electrophotographic Laser'
5 = 'Electrophotographic Other'
6 = 'Impact Moving Head Dot Matrix 9pin'
7 = 'Impact Moving Head Dot Matrix 24pin'
8 = 'Impact Moving Head Dot Matrix Other'
9 = 'Impact Moving Head Fully Formed'
10 = 'Impact Band'
11 = 'Impact Other'
12 = 'Inkjet Aqueous'
13 = 'Inkjet Solid'
14 = 'Inkjet Other'
15 = 'Pen'
16 = 'Thermal Transfer'
17 = 'Thermal Sensitive'
18 = 'Thermal Diffusion'
19 = 'Thermal Other'
20 = 'Electroerosion'
21 = 'Electrostatic'
22 = 'Photographic Microfiche'
23 = 'Photographic Imagesetter'
24 = 'Photographic Other'
25 = 'Ion Deposition'
26 = 'eBeam'
27 = 'Typesetter'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_Printer | 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.MarkingTechnology
# translate raw value to friendly text:
$friendlyName = $MarkingTechnology_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 "MarkingTechnology" 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 "MarkingTechnology", 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 "MarkingTechnology", 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:
#>
$MarkingTechnology = @{
Name = 'MarkingTechnology'
Expression = {
# property is an array, so process all values
$value = $_.MarkingTechnology
switch([int]$value)
{
1 {'Other'}
2 {'Unknown'}
3 {'Electrophotographic LED'}
4 {'Electrophotographic Laser'}
5 {'Electrophotographic Other'}
6 {'Impact Moving Head Dot Matrix 9pin'}
7 {'Impact Moving Head Dot Matrix 24pin'}
8 {'Impact Moving Head Dot Matrix Other'}
9 {'Impact Moving Head Fully Formed'}
10 {'Impact Band'}
11 {'Impact Other'}
12 {'Inkjet Aqueous'}
13 {'Inkjet Solid'}
14 {'Inkjet Other'}
15 {'Pen'}
16 {'Thermal Transfer'}
17 {'Thermal Sensitive'}
18 {'Thermal Diffusion'}
19 {'Thermal Other'}
20 {'Electroerosion'}
21 {'Electrostatic'}
22 {'Photographic Microfiche'}
23 {'Photographic Imagesetter'}
24 {'Photographic Other'}
25 {'Ion Deposition'}
26 {'eBeam'}
27 {'Typesetter'}
default {"$value"}
}
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_Printer |
# ...and output properties "Caption" and "MarkingTechnology". The latter is defined
# by the hashtable in $MarkingTechnology:
Select-Object -Property Caption, $MarkingTechnology
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_Printer", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumMarkingTechnology
{
Other = 1
Unknown = 2
Electrophotographic_LED = 3
Electrophotographic_Laser = 4
Electrophotographic_Other = 5
Impact_Moving_Head_Dot_Matrix_9pin = 6
Impact_Moving_Head_Dot_Matrix_24pin = 7
Impact_Moving_Head_Dot_Matrix_Other = 8
Impact_Moving_Head_Fully_Formed = 9
Impact_Band = 10
Impact_Other = 11
Inkjet_Aqueous = 12
Inkjet_Solid = 13
Inkjet_Other = 14
Pen = 15
Thermal_Transfer = 16
Thermal_Sensitive = 17
Thermal_Diffusion = 18
Thermal_Other = 19
Electroerosion = 20
Electrostatic = 21
Photographic_Microfiche = 22
Photographic_Imagesetter = 23
Photographic_Other = 24
Ion_Deposition = 25
eBeam = 26
Typesetter = 27
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_Printer | 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.MarkingTechnology
#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 **MarkingTechnology**
[EnumMarkingTechnology]$rawValue
# get a comma-separated string:
[EnumMarkingTechnology]$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 [EnumMarkingTechnology]
#endregion
Enums must cover all possible values. If MarkingTechnology 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.
MaxCopies
Maximum number of copies the printer can produce for one job.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property MaxCopies
MaxNumberUp
Maximum number of print-stream pages the printer can render on one media sheet, such as paper.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property MaxNumberUp
MaxSizeSupported
Largest job as a byte stream, in kilobytes, that the printer can accept. A value of 0 (zero) indicates that no limit is set.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property MaxSizeSupported
MimeTypesSupported
Array of detailed MIME-type explanations that the printer supports. If data is provided, then the value 47 (“MIME”) must be included in the LanguagesSupported property.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property MimeTypesSupported
Name
Name of the printer.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property Name
NaturalLanguagesSupported
Array of languages supported for strings that the printer uses for output of management information. Must conform to RFC® 1766. For example, “en” is used for English.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property NaturalLanguagesSupported
Network
If TRUE, the printer is a network printer. If both the Local and Network properties are set to TRUE, then the printer is a network printer.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property Network
PaperSizesSupported
Array of the paper types that the printer supports.
PaperSizesSupported returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$PaperSizesSupported_map = @{
0 = 'Unknown'
1 = 'Other'
2 = 'A'
3 = 'B'
4 = 'C'
5 = 'D'
6 = 'E'
7 = 'Letter'
8 = 'Legal'
9 = 'NA-10x13-Envelope'
10 = 'NA-9x12-Envelope'
11 = 'NA-Number-10-Envelope'
12 = 'NA-7x9-Envelope'
13 = 'NA-9x11-Envelope'
14 = 'NA-10x14-Envelope'
15 = 'NA-Number-9-Envelope'
16 = 'NA-6x9-Envelope'
17 = 'NA-10x15-Envelope'
18 = 'A0'
19 = 'A1'
20 = 'A2'
21 = 'A3'
22 = 'A4'
23 = 'A5'
24 = 'A6'
25 = 'A7'
26 = 'A8'
27 = 'A9A10'
28 = 'B0'
29 = 'B1'
30 = 'B2'
31 = 'B3'
32 = 'B4'
33 = 'B5'
34 = 'B6'
35 = 'B7'
36 = 'B8'
37 = 'B9'
38 = 'B10'
39 = 'C0'
40 = 'C1'
41 = 'C2C3'
42 = 'C4'
43 = 'C5'
44 = 'C6'
45 = 'C7'
46 = 'C8'
47 = 'ISO-Designated'
48 = 'JIS B0'
49 = 'JIS B1'
50 = 'JIS B2'
51 = 'JIS B3'
52 = 'JIS B4'
53 = 'JIS B5'
54 = 'JIS B6'
55 = 'JIS B7'
56 = 'JIS B8'
57 = 'JIS B9'
58 = 'JIS B10'
59 = 'NA-Letter'
60 = 'NA-Legal'
61 = 'B4-Envelope'
62 = 'B5-Envelope'
63 = 'C3-Envelope'
64 = 'C4-Envelope'
65 = 'C5-Envelope'
66 = 'C6-Envelope'
67 = 'Designated-Long-Envelope'
68 = 'Monarch-Envelope'
69 = 'Executive'
70 = 'Folio'
71 = 'Invoice'
72 = 'Ledger'
73 = 'Quarto'
}
Use a switch statement
switch([int]$value)
{
0 {'Unknown'}
1 {'Other'}
2 {'A'}
3 {'B'}
4 {'C'}
5 {'D'}
6 {'E'}
7 {'Letter'}
8 {'Legal'}
9 {'NA-10x13-Envelope'}
10 {'NA-9x12-Envelope'}
11 {'NA-Number-10-Envelope'}
12 {'NA-7x9-Envelope'}
13 {'NA-9x11-Envelope'}
14 {'NA-10x14-Envelope'}
15 {'NA-Number-9-Envelope'}
16 {'NA-6x9-Envelope'}
17 {'NA-10x15-Envelope'}
18 {'A0'}
19 {'A1'}
20 {'A2'}
21 {'A3'}
22 {'A4'}
23 {'A5'}
24 {'A6'}
25 {'A7'}
26 {'A8'}
27 {'A9A10'}
28 {'B0'}
29 {'B1'}
30 {'B2'}
31 {'B3'}
32 {'B4'}
33 {'B5'}
34 {'B6'}
35 {'B7'}
36 {'B8'}
37 {'B9'}
38 {'B10'}
39 {'C0'}
40 {'C1'}
41 {'C2C3'}
42 {'C4'}
43 {'C5'}
44 {'C6'}
45 {'C7'}
46 {'C8'}
47 {'ISO-Designated'}
48 {'JIS B0'}
49 {'JIS B1'}
50 {'JIS B2'}
51 {'JIS B3'}
52 {'JIS B4'}
53 {'JIS B5'}
54 {'JIS B6'}
55 {'JIS B7'}
56 {'JIS B8'}
57 {'JIS B9'}
58 {'JIS B10'}
59 {'NA-Letter'}
60 {'NA-Legal'}
61 {'B4-Envelope'}
62 {'B5-Envelope'}
63 {'C3-Envelope'}
64 {'C4-Envelope'}
65 {'C5-Envelope'}
66 {'C6-Envelope'}
67 {'Designated-Long-Envelope'}
68 {'Monarch-Envelope'}
69 {'Executive'}
70 {'Folio'}
71 {'Invoice'}
72 {'Ledger'}
73 {'Quarto'}
default {"$value"}
}
Use Enum structure
Enum EnumPaperSizesSupported
{
Unknown = 0
Other = 1
A = 2
B = 3
C = 4
D = 5
E = 6
Letter = 7
Legal = 8
NA_10x13_Envelope = 9
NA_9x12_Envelope = 10
NA_Number_10_Envelope = 11
NA_7x9_Envelope = 12
NA_9x11_Envelope = 13
NA_10x14_Envelope = 14
NA_Number_9_Envelope = 15
NA_6x9_Envelope = 16
NA_10x15_Envelope = 17
A0 = 18
A1 = 19
A2 = 20
A3 = 21
A4 = 22
A5 = 23
A6 = 24
A7 = 25
A8 = 26
A9A10 = 27
B0 = 28
B1 = 29
B2 = 30
B3 = 31
B4 = 32
B5 = 33
B6 = 34
B7 = 35
B8 = 36
B9 = 37
B10 = 38
C0 = 39
C1 = 40
C2C3 = 41
C4 = 42
C5 = 43
C6 = 44
C7 = 45
C8 = 46
ISO_Designated = 47
JIS_B0 = 48
JIS_B1 = 49
JIS_B2 = 50
JIS_B3 = 51
JIS_B4 = 52
JIS_B5 = 53
JIS_B6 = 54
JIS_B7 = 55
JIS_B8 = 56
JIS_B9 = 57
JIS_B10 = 58
NA_Letter = 59
NA_Legal = 60
B4_Envelope = 61
B5_Envelope = 62
C3_Envelope = 63
C4_Envelope = 64
C5_Envelope = 65
C6_Envelope = 66
Designated_Long_Envelope = 67
Monarch_Envelope = 68
Executive = 69
Folio = 70
Invoice = 71
Ledger = 72
Quarto = 73
}
Examples
Use $PaperSizesSupported_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "PaperSizesSupported" to friendly text
Note: to use other properties than "PaperSizesSupported", 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 "PaperSizesSupported"
# to translate other properties, use their translation table instead
$PaperSizesSupported_map = @{
0 = 'Unknown'
1 = 'Other'
2 = 'A'
3 = 'B'
4 = 'C'
5 = 'D'
6 = 'E'
7 = 'Letter'
8 = 'Legal'
9 = 'NA-10x13-Envelope'
10 = 'NA-9x12-Envelope'
11 = 'NA-Number-10-Envelope'
12 = 'NA-7x9-Envelope'
13 = 'NA-9x11-Envelope'
14 = 'NA-10x14-Envelope'
15 = 'NA-Number-9-Envelope'
16 = 'NA-6x9-Envelope'
17 = 'NA-10x15-Envelope'
18 = 'A0'
19 = 'A1'
20 = 'A2'
21 = 'A3'
22 = 'A4'
23 = 'A5'
24 = 'A6'
25 = 'A7'
26 = 'A8'
27 = 'A9A10'
28 = 'B0'
29 = 'B1'
30 = 'B2'
31 = 'B3'
32 = 'B4'
33 = 'B5'
34 = 'B6'
35 = 'B7'
36 = 'B8'
37 = 'B9'
38 = 'B10'
39 = 'C0'
40 = 'C1'
41 = 'C2C3'
42 = 'C4'
43 = 'C5'
44 = 'C6'
45 = 'C7'
46 = 'C8'
47 = 'ISO-Designated'
48 = 'JIS B0'
49 = 'JIS B1'
50 = 'JIS B2'
51 = 'JIS B3'
52 = 'JIS B4'
53 = 'JIS B5'
54 = 'JIS B6'
55 = 'JIS B7'
56 = 'JIS B8'
57 = 'JIS B9'
58 = 'JIS B10'
59 = 'NA-Letter'
60 = 'NA-Legal'
61 = 'B4-Envelope'
62 = 'B5-Envelope'
63 = 'C3-Envelope'
64 = 'C4-Envelope'
65 = 'C5-Envelope'
66 = 'C6-Envelope'
67 = 'Designated-Long-Envelope'
68 = 'Monarch-Envelope'
69 = 'Executive'
70 = 'Folio'
71 = 'Invoice'
72 = 'Ledger'
73 = 'Quarto'
}
#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 "PaperSizesSupported", 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:
#>
$PaperSizesSupported = @{
Name = 'PaperSizesSupported'
Expression = {
# property is an array, so process all values
$result = foreach($value in $_.PaperSizesSupported)
{
# important: convert original value to [int] because
# hashtable keys are type-aware:
$PaperSizesSupported_map[[int]$value]
}
# uncomment to get a comma-separated string instead
# of a string array:
$result <#-join ', '#>
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "PaperSizesSupported". The latter
# is defined by the hashtable in $PaperSizesSupported:
Get-CimInstance -Class Win32_Printer | Select-Object -Property Caption, $PaperSizesSupported
# ...or dump content of property PaperSizesSupported:
$friendlyValues = Get-CimInstance -Class Win32_Printer |
Select-Object -Property $PaperSizesSupported |
Select-Object -ExpandProperty PaperSizesSupported
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $PaperSizesSupported_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_Printer" to friendly text. This approach is ideal when there
is just one instance to work with.
Note: to use other properties than "Win32_Printer", 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_Printer"
# to translate other properties, use their translation table instead
$PaperSizesSupported_map = @{
0 = 'Unknown'
1 = 'Other'
2 = 'A'
3 = 'B'
4 = 'C'
5 = 'D'
6 = 'E'
7 = 'Letter'
8 = 'Legal'
9 = 'NA-10x13-Envelope'
10 = 'NA-9x12-Envelope'
11 = 'NA-Number-10-Envelope'
12 = 'NA-7x9-Envelope'
13 = 'NA-9x11-Envelope'
14 = 'NA-10x14-Envelope'
15 = 'NA-Number-9-Envelope'
16 = 'NA-6x9-Envelope'
17 = 'NA-10x15-Envelope'
18 = 'A0'
19 = 'A1'
20 = 'A2'
21 = 'A3'
22 = 'A4'
23 = 'A5'
24 = 'A6'
25 = 'A7'
26 = 'A8'
27 = 'A9A10'
28 = 'B0'
29 = 'B1'
30 = 'B2'
31 = 'B3'
32 = 'B4'
33 = 'B5'
34 = 'B6'
35 = 'B7'
36 = 'B8'
37 = 'B9'
38 = 'B10'
39 = 'C0'
40 = 'C1'
41 = 'C2C3'
42 = 'C4'
43 = 'C5'
44 = 'C6'
45 = 'C7'
46 = 'C8'
47 = 'ISO-Designated'
48 = 'JIS B0'
49 = 'JIS B1'
50 = 'JIS B2'
51 = 'JIS B3'
52 = 'JIS B4'
53 = 'JIS B5'
54 = 'JIS B6'
55 = 'JIS B7'
56 = 'JIS B8'
57 = 'JIS B9'
58 = 'JIS B10'
59 = 'NA-Letter'
60 = 'NA-Legal'
61 = 'B4-Envelope'
62 = 'B5-Envelope'
63 = 'C3-Envelope'
64 = 'C4-Envelope'
65 = 'C5-Envelope'
66 = 'C6-Envelope'
67 = 'Designated-Long-Envelope'
68 = 'Monarch-Envelope'
69 = 'Executive'
70 = 'Folio'
71 = 'Invoice'
72 = 'Ledger'
73 = 'Quarto'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_Printer | 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 (hint: the property is an array!)
$rawValues = $instance.PaperSizesSupported
# translate all raw values into friendly names:
$friendlyNames = foreach($rawValue in $rawValues)
{ $PaperSizesSupported_map[[int]$rawValue] }
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use a switch statement inside a calculated property for Select-Object
<#
this example uses a switch clause to translate raw numeric
values for property "PaperSizesSupported" 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 "PaperSizesSupported", 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 "PaperSizesSupported", 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:
#>
$PaperSizesSupported = @{
Name = 'PaperSizesSupported'
Expression = {
# property is an array, so process all values
$result = foreach($value in $_.PaperSizesSupported)
{
switch([int]$value)
{
0 {'Unknown'}
1 {'Other'}
2 {'A'}
3 {'B'}
4 {'C'}
5 {'D'}
6 {'E'}
7 {'Letter'}
8 {'Legal'}
9 {'NA-10x13-Envelope'}
10 {'NA-9x12-Envelope'}
11 {'NA-Number-10-Envelope'}
12 {'NA-7x9-Envelope'}
13 {'NA-9x11-Envelope'}
14 {'NA-10x14-Envelope'}
15 {'NA-Number-9-Envelope'}
16 {'NA-6x9-Envelope'}
17 {'NA-10x15-Envelope'}
18 {'A0'}
19 {'A1'}
20 {'A2'}
21 {'A3'}
22 {'A4'}
23 {'A5'}
24 {'A6'}
25 {'A7'}
26 {'A8'}
27 {'A9A10'}
28 {'B0'}
29 {'B1'}
30 {'B2'}
31 {'B3'}
32 {'B4'}
33 {'B5'}
34 {'B6'}
35 {'B7'}
36 {'B8'}
37 {'B9'}
38 {'B10'}
39 {'C0'}
40 {'C1'}
41 {'C2C3'}
42 {'C4'}
43 {'C5'}
44 {'C6'}
45 {'C7'}
46 {'C8'}
47 {'ISO-Designated'}
48 {'JIS B0'}
49 {'JIS B1'}
50 {'JIS B2'}
51 {'JIS B3'}
52 {'JIS B4'}
53 {'JIS B5'}
54 {'JIS B6'}
55 {'JIS B7'}
56 {'JIS B8'}
57 {'JIS B9'}
58 {'JIS B10'}
59 {'NA-Letter'}
60 {'NA-Legal'}
61 {'B4-Envelope'}
62 {'B5-Envelope'}
63 {'C3-Envelope'}
64 {'C4-Envelope'}
65 {'C5-Envelope'}
66 {'C6-Envelope'}
67 {'Designated-Long-Envelope'}
68 {'Monarch-Envelope'}
69 {'Executive'}
70 {'Folio'}
71 {'Invoice'}
72 {'Ledger'}
73 {'Quarto'}
default {"$value"}
}
}
$result
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_Printer |
# ...and output properties "Caption" and "PaperSizesSupported". The latter is defined
# by the hashtable in $PaperSizesSupported:
Select-Object -Property Caption, $PaperSizesSupported
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_Printer", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumPaperSizesSupported
{
Unknown = 0
Other = 1
A = 2
B = 3
C = 4
D = 5
E = 6
Letter = 7
Legal = 8
NA_10x13_Envelope = 9
NA_9x12_Envelope = 10
NA_Number_10_Envelope = 11
NA_7x9_Envelope = 12
NA_9x11_Envelope = 13
NA_10x14_Envelope = 14
NA_Number_9_Envelope = 15
NA_6x9_Envelope = 16
NA_10x15_Envelope = 17
A0 = 18
A1 = 19
A2 = 20
A3 = 21
A4 = 22
A5 = 23
A6 = 24
A7 = 25
A8 = 26
A9A10 = 27
B0 = 28
B1 = 29
B2 = 30
B3 = 31
B4 = 32
B5 = 33
B6 = 34
B7 = 35
B8 = 36
B9 = 37
B10 = 38
C0 = 39
C1 = 40
C2C3 = 41
C4 = 42
C5 = 43
C6 = 44
C7 = 45
C8 = 46
ISO_Designated = 47
JIS_B0 = 48
JIS_B1 = 49
JIS_B2 = 50
JIS_B3 = 51
JIS_B4 = 52
JIS_B5 = 53
JIS_B6 = 54
JIS_B7 = 55
JIS_B8 = 56
JIS_B9 = 57
JIS_B10 = 58
NA_Letter = 59
NA_Legal = 60
B4_Envelope = 61
B5_Envelope = 62
C3_Envelope = 63
C4_Envelope = 64
C5_Envelope = 65
C6_Envelope = 66
Designated_Long_Envelope = 67
Monarch_Envelope = 68
Executive = 69
Folio = 70
Invoice = 71
Ledger = 72
Quarto = 73
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_Printer | 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.PaperSizesSupported
#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 **PaperSizesSupported**
[EnumPaperSizesSupported[]]$rawValue
# get a comma-separated string:
[EnumPaperSizesSupported[]]$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 [EnumPaperSizesSupported[]]
#endregion
Enums must cover all possible values. If PaperSizesSupported 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.
PaperTypesAvailable
Array of paper types that are currently available on the printer. Each string must be expressed in the format specified by ISO/IEC® 10175 Document Printing Application (DPA), which is summarized in Appendix® C of RFC® 1759 (Printer MIB). Any paper size identified in this property must also appear in the PaperSizesSupported property.
Example: iso-a4-colored
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property PaperTypesAvailable
Parameters
Optional parameters for the print processor.
Example: “Copies=2”
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property Parameters
PNPDeviceID
Windows Plug and Play device identifier of the logical device.
Example: *PNP030b
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property PNPDeviceID
PortName
Port that is used to transmit data to a printer. If a printer is connected to more than one port, the names of each port are separated by commas.
Example: LPT1:, LPT2:, LPT3:
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property PortName
PowerManagementCapabilities
Array of the specific power-related capabilities of a logical device.
PowerManagementCapabilities returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$PowerManagementCapabilities_map = @{
0 = 'Unknown'
1 = 'Not Supported'
2 = 'Disabled'
3 = 'Enabled'
4 = 'Power Saving Modes Entered Automatically'
5 = 'Power State Settable'
6 = 'Power Cycling Supported'
7 = 'Timed Power On Supported'
}
Use a switch statement
switch([int]$value)
{
0 {'Unknown'}
1 {'Not Supported'}
2 {'Disabled'}
3 {'Enabled'}
4 {'Power Saving Modes Entered Automatically'}
5 {'Power State Settable'}
6 {'Power Cycling Supported'}
7 {'Timed Power On Supported'}
default {"$value"}
}
Use Enum structure
Enum EnumPowerManagementCapabilities
{
Unknown = 0
Not_Supported = 1
Disabled = 2
Enabled = 3
Power_Saving_Modes_Entered_Automatically = 4
Power_State_Settable = 5
Power_Cycling_Supported = 6
Timed_Power_On_Supported = 7
}
Examples
Use $PowerManagementCapabilities_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "PowerManagementCapabilities" to friendly text
Note: to use other properties than "PowerManagementCapabilities", 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 "PowerManagementCapabilities"
# to translate other properties, use their translation table instead
$PowerManagementCapabilities_map = @{
0 = 'Unknown'
1 = 'Not Supported'
2 = 'Disabled'
3 = 'Enabled'
4 = 'Power Saving Modes Entered Automatically'
5 = 'Power State Settable'
6 = 'Power Cycling Supported'
7 = 'Timed Power On Supported'
}
#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 "PowerManagementCapabilities", 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:
#>
$PowerManagementCapabilities = @{
Name = 'PowerManagementCapabilities'
Expression = {
# property is an array, so process all values
$result = foreach($value in $_.PowerManagementCapabilities)
{
# important: convert original value to [int] because
# hashtable keys are type-aware:
$PowerManagementCapabilities_map[[int]$value]
}
# uncomment to get a comma-separated string instead
# of a string array:
$result <#-join ', '#>
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "PowerManagementCapabilities". The latter
# is defined by the hashtable in $PowerManagementCapabilities:
Get-CimInstance -Class Win32_Printer | Select-Object -Property Caption, $PowerManagementCapabilities
# ...or dump content of property PowerManagementCapabilities:
$friendlyValues = Get-CimInstance -Class Win32_Printer |
Select-Object -Property $PowerManagementCapabilities |
Select-Object -ExpandProperty PowerManagementCapabilities
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $PowerManagementCapabilities_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_Printer" to friendly text. This approach is ideal when there
is just one instance to work with.
Note: to use other properties than "Win32_Printer", 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_Printer"
# to translate other properties, use their translation table instead
$PowerManagementCapabilities_map = @{
0 = 'Unknown'
1 = 'Not Supported'
2 = 'Disabled'
3 = 'Enabled'
4 = 'Power Saving Modes Entered Automatically'
5 = 'Power State Settable'
6 = 'Power Cycling Supported'
7 = 'Timed Power On Supported'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_Printer | 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 (hint: the property is an array!)
$rawValues = $instance.PowerManagementCapabilities
# translate all raw values into friendly names:
$friendlyNames = foreach($rawValue in $rawValues)
{ $PowerManagementCapabilities_map[[int]$rawValue] }
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use a switch statement inside a calculated property for Select-Object
<#
this example uses a switch clause to translate raw numeric
values for property "PowerManagementCapabilities" 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 "PowerManagementCapabilities", 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 "PowerManagementCapabilities", 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:
#>
$PowerManagementCapabilities = @{
Name = 'PowerManagementCapabilities'
Expression = {
# property is an array, so process all values
$result = foreach($value in $_.PowerManagementCapabilities)
{
switch([int]$value)
{
0 {'Unknown'}
1 {'Not Supported'}
2 {'Disabled'}
3 {'Enabled'}
4 {'Power Saving Modes Entered Automatically'}
5 {'Power State Settable'}
6 {'Power Cycling Supported'}
7 {'Timed Power On Supported'}
default {"$value"}
}
}
$result
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_Printer |
# ...and output properties "Caption" and "PowerManagementCapabilities". The latter is defined
# by the hashtable in $PowerManagementCapabilities:
Select-Object -Property Caption, $PowerManagementCapabilities
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_Printer", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumPowerManagementCapabilities
{
Unknown = 0
Not_Supported = 1
Disabled = 2
Enabled = 3
Power_Saving_Modes_Entered_Automatically = 4
Power_State_Settable = 5
Power_Cycling_Supported = 6
Timed_Power_On_Supported = 7
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_Printer | 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.PowerManagementCapabilities
#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 **PowerManagementCapabilities**
[EnumPowerManagementCapabilities[]]$rawValue
# get a comma-separated string:
[EnumPowerManagementCapabilities[]]$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 [EnumPowerManagementCapabilities[]]
#endregion
Enums must cover all possible values. If PowerManagementCapabilities 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.
PowerManagementSupported
If TRUE, the power of the device can be managed, which means that it can be put into suspend mode. The property does not indicate that power management features are enabled, only that the logical device is capable of power management.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property PowerManagementSupported
PrinterPaperNames
Array of paper sizes supported by the printer. The printer-specified names are used to represent supported paper sizes.
Example: B5 (JIS)
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property PrinterPaperNames
PrinterState
One of the possible states relating to this printer. This property is obsolete. In place of this property, use PrinterStatus.
0
Idle - for more information, see the Remarks section below.
1
Paused
2
Error
3
Pending Deletion
4
Paper Jam
5
Paper Out
6
Manual Feed
7
Paper Problem
8
Offline
9
I/O Active
10
Busy
11
Printing
12
Output Bin Full
13
Not Available
14
Waiting
15
Processing
16
Initialization
17
Warming Up
18
Toner Low
19
No Toner
20
Page Punt
21
User Intervention Required
22
Out of Memory
23
Door Open
24
Server_Unknown
25
Power Save
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property PrinterState
PrinterStatus
Status information for a printer that is different from information specified in the logical device Availability property.
PrinterStatus returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$PrinterStatus_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Idle'
4 = 'Printing'
5 = 'Warmup'
6 = 'Stopped Printing'
7 = 'Offline'
}
Use a switch statement
switch([int]$value)
{
1 {'Other'}
2 {'Unknown'}
3 {'Idle'}
4 {'Printing'}
5 {'Warmup'}
6 {'Stopped Printing'}
7 {'Offline'}
default {"$value"}
}
Use Enum structure
Enum EnumPrinterStatus
{
Other = 1
Unknown = 2
Idle = 3
Printing = 4
Warmup = 5
Stopped_Printing = 6
Offline = 7
}
Examples
Use $PrinterStatus_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "PrinterStatus" to friendly text
Note: to use other properties than "PrinterStatus", 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 "PrinterStatus"
# to translate other properties, use their translation table instead
$PrinterStatus_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Idle'
4 = 'Printing'
5 = 'Warmup'
6 = 'Stopped Printing'
7 = 'Offline'
}
#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 "PrinterStatus", 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:
#>
$PrinterStatus = @{
Name = 'PrinterStatus'
Expression = {
# property is an array, so process all values
$value = $_.PrinterStatus
$PrinterStatus_map[[int]$value]
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "PrinterStatus". The latter
# is defined by the hashtable in $PrinterStatus:
Get-CimInstance -Class Win32_Printer | Select-Object -Property Caption, $PrinterStatus
# ...or dump content of property PrinterStatus:
$friendlyValues = Get-CimInstance -Class Win32_Printer |
Select-Object -Property $PrinterStatus |
Select-Object -ExpandProperty PrinterStatus
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $PrinterStatus_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_Printer" to friendly text. This approach is ideal when
there is just one instance to work with.
Note: to use other properties than "Win32_Printer", 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_Printer"
# to translate other properties, use their translation table instead
$PrinterStatus_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Idle'
4 = 'Printing'
5 = 'Warmup'
6 = 'Stopped Printing'
7 = 'Offline'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_Printer | 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.PrinterStatus
# translate raw value to friendly text:
$friendlyName = $PrinterStatus_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 "PrinterStatus" 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 "PrinterStatus", 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 "PrinterStatus", 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:
#>
$PrinterStatus = @{
Name = 'PrinterStatus'
Expression = {
# property is an array, so process all values
$value = $_.PrinterStatus
switch([int]$value)
{
1 {'Other'}
2 {'Unknown'}
3 {'Idle'}
4 {'Printing'}
5 {'Warmup'}
6 {'Stopped Printing'}
7 {'Offline'}
default {"$value"}
}
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_Printer |
# ...and output properties "Caption" and "PrinterStatus". The latter is defined
# by the hashtable in $PrinterStatus:
Select-Object -Property Caption, $PrinterStatus
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_Printer", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumPrinterStatus
{
Other = 1
Unknown = 2
Idle = 3
Printing = 4
Warmup = 5
Stopped_Printing = 6
Offline = 7
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_Printer | 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.PrinterStatus
#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 **PrinterStatus**
[EnumPrinterStatus]$rawValue
# get a comma-separated string:
[EnumPrinterStatus]$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 [EnumPrinterStatus]
#endregion
Enums must cover all possible values. If PrinterStatus 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.
PrintJobDataType
Data type of a print job waiting for the Windows-based printing device.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property PrintJobDataType
PrintProcessor
Name of the print spooler that handles print jobs.
Example: SPOOLSS.DLL
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property PrintProcessor
Priority
Priority of the printer. Jobs on a higher priority printer are scheduled first.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property Priority
Published
If TRUE, the printer is published in the network directory service.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property Published
Queued
If TRUE, the printer buffers and queues print jobs.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property Queued
RawOnly
If TRUE, the printer accepts only raw data to be spooled.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property RawOnly
SeparatorFile
Name of the file used to create a separator page. This page is used to separate print jobs sent to the printer.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property SeparatorFile
ServerName
Name of the server that controls the printer. If this string is NULL, the printer is controlled locally.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property ServerName
Shared
If TRUE, the printer is available as a shared network resource.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property Shared
ShareName
Share name of the Windows-based printing device.
Example: “\PRINTSERVER1\PRINTER2”
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property ShareName
SpoolEnabled
This property is obsolete; do not use. If TRUE, spooling is enabled for printer.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property SpoolEnabled
StartTime
Date and time that a printer can start to print a jobâif the printer is limited to print at specific times. This value is expressed as the time elapsed since 12:00 AM GMT (Greenwich Mean Time).
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property StartTime
Status
Current status of an object. Various operational and nonoperational statuses can be defined. Available values:
$values = 'Degraded','Error','Lost Comm','No Contact','NonRecover','OK','Pred Fail','Service','Starting','Stopping','Stressed','Unknown'
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property Status
StatusInfo
State of the logical device. If this property does not apply to the logical device, the value 5 (Not Applicable) should be used.
StatusInfo returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$StatusInfo_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Enabled'
4 = 'Disabled'
5 = 'Not Applicable'
}
Use a switch statement
switch([int]$value)
{
1 {'Other'}
2 {'Unknown'}
3 {'Enabled'}
4 {'Disabled'}
5 {'Not Applicable'}
default {"$value"}
}
Use Enum structure
Enum EnumStatusInfo
{
Other = 1
Unknown = 2
Enabled = 3
Disabled = 4
Not_Applicable = 5
}
Examples
Use $StatusInfo_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "StatusInfo" to friendly text
Note: to use other properties than "StatusInfo", 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 "StatusInfo"
# to translate other properties, use their translation table instead
$StatusInfo_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Enabled'
4 = 'Disabled'
5 = 'Not Applicable'
}
#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 "StatusInfo", 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:
#>
$StatusInfo = @{
Name = 'StatusInfo'
Expression = {
# property is an array, so process all values
$value = $_.StatusInfo
$StatusInfo_map[[int]$value]
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "StatusInfo". The latter
# is defined by the hashtable in $StatusInfo:
Get-CimInstance -Class Win32_Printer | Select-Object -Property Caption, $StatusInfo
# ...or dump content of property StatusInfo:
$friendlyValues = Get-CimInstance -Class Win32_Printer |
Select-Object -Property $StatusInfo |
Select-Object -ExpandProperty StatusInfo
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $StatusInfo_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_Printer" to friendly text. This approach is ideal when
there is just one instance to work with.
Note: to use other properties than "Win32_Printer", 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_Printer"
# to translate other properties, use their translation table instead
$StatusInfo_map = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Enabled'
4 = 'Disabled'
5 = 'Not Applicable'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_Printer | 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.StatusInfo
# translate raw value to friendly text:
$friendlyName = $StatusInfo_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 "StatusInfo" 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 "StatusInfo", 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 "StatusInfo", 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:
#>
$StatusInfo = @{
Name = 'StatusInfo'
Expression = {
# property is an array, so process all values
$value = $_.StatusInfo
switch([int]$value)
{
1 {'Other'}
2 {'Unknown'}
3 {'Enabled'}
4 {'Disabled'}
5 {'Not Applicable'}
default {"$value"}
}
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_Printer |
# ...and output properties "Caption" and "StatusInfo". The latter is defined
# by the hashtable in $StatusInfo:
Select-Object -Property Caption, $StatusInfo
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_Printer", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumStatusInfo
{
Other = 1
Unknown = 2
Enabled = 3
Disabled = 4
Not_Applicable = 5
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_Printer | 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.StatusInfo
#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 **StatusInfo**
[EnumStatusInfo]$rawValue
# get a comma-separated string:
[EnumStatusInfo]$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 [EnumStatusInfo]
#endregion
Enums must cover all possible values. If StatusInfo 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.
SystemCreationClassName
Value of the scoping computer’s CreationClassName property.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property SystemCreationClassName
SystemName
Name of the scoping system.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property SystemName
TimeOfLastReset
Date and time the printer was last reset.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property TimeOfLastReset
UntilTime
Date and time that a printer can print the last jobâif the printer is limited to print at specific times. This value is expressed as the time elapsed since 12:00 AM GMT (Greenwich Mean Time).
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property UntilTime
VerticalResolution
Vertical resolution, in pixels-per-inch, of the printer.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property VerticalResolution
WorkOffline
If TRUE, you can queue print jobs on the computer when the printer is offline.
Get-CimInstance -ClassName Win32_Printer | Select-Object -Property WorkOffline
Examples
List all instances of Win32_Printer
Get-CimInstance -ClassName Win32_Printer
Learn more about Get-CimInstance
and the deprecated Get-WmiObject
.
View all properties
Get-CimInstance -ClassName Win32_Printer -Property *
View key properties only
Get-CimInstance -ClassName Win32_Printer -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 = 'Attributes',
'Availability',
'AvailableJobSheets',
'AveragePagesPerMinute',
'Capabilities',
'CapabilityDescriptions',
'Caption',
'CharSetsSupported',
'Comment',
'ConfigManagerErrorCode',
'ConfigManagerUserConfig',
'CreationClassName',
'CurrentCapabilities',
'CurrentCharSet',
'CurrentLanguage',
'CurrentMimeType',
'CurrentNaturalLanguage',
'CurrentPaperType',
'Default',
'DefaultCapabilities',
'DefaultCopies',
'DefaultLanguage',
'DefaultMimeType',
'DefaultNumberUp',
'DefaultPaperType',
'DefaultPriority',
'Description',
'DetectedErrorState',
'DeviceID',
'Direct',
'DoCompleteFirst',
'DriverName',
'EnableBIDI',
'EnableDevQueryPrint',
'ErrorCleared',
'ErrorDescription',
'ErrorInformation',
'ExtendedDetectedErrorState',
'ExtendedPrinterStatus',
'Hidden',
'HorizontalResolution',
'InstallDate',
'JobCountSinceLastReset',
'KeepPrintedJobs',
'LanguagesSupported',
'LastErrorCode',
'Local',
'Location',
'MarkingTechnology',
'MaxCopies',
'MaxNumberUp',
'MaxSizeSupported',
'MimeTypesSupported',
'Name',
'NaturalLanguagesSupported',
'Network',
'PaperSizesSupported',
'PaperTypesAvailable',
'Parameters',
'PNPDeviceID',
'PortName',
'PowerManagementCapabilities',
'PowerManagementSupported',
'PrinterPaperNames',
'PrinterState',
'PrinterStatus',
'PrintJobDataType',
'PrintProcessor',
'Priority',
'Published',
'Queued',
'RawOnly',
'SeparatorFile',
'ServerName',
'Shared',
'ShareName',
'SpoolEnabled',
'StartTime',
'Status',
'StatusInfo',
'SystemCreationClassName',
'SystemName',
'TimeOfLastReset',
'UntilTime',
'VerticalResolution',
'WorkOffline'
Get-CimInstance -ClassName Win32_Printer | 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_Printer -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_Printer -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 ErrorInformation, Network, Shared, Priority FROM Win32_Printer 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 ErrorInformation, Network, Shared, Priority FROM Win32_Printer WHERE Caption LIKE 'a%'" | Select-Object -Property ErrorInformation, Network, Shared, Priority
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_Printer -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_Printer -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_Printer, 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_Printer was introduced on clients with Windows Vista and on servers with Windows Server 2008.
Namespace
Win32_Printer 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_Printer is implemented in CIMWin32.dll and defined in Win32_Printer.mof. Both files are located in the folder C:\Windows\system32\wbem
:
explorer $env:windir\system32\wbem
notepad $env:windir\system32\wbem\Win32_Printer.mof