The Get-CMDevice cmdlet gets a Configuration Manager device. By default it queries the SMS_CM_RES_COLL_SMS00001 class. You can use the Resource or CollectionMember parameters to change the query class. Depending upon your role-based access in the site, you may need to use one of these other parameters. For example, if you don't have access to SMS00001, then by default this cmdlet returns zero results.
Note
Run Configuration Manager cmdlets from the Configuration Manager site drive, for example PS XYZ:\>. For more information, see getting started.
Examples
Example 1: Get devices by collection ID
This command gets all the device objects in the device collection with the ID of XYZ0004B. It uses the Select-Object cmdlet to only display specific properties.
Name : DEVICE-LT3
ClientVersion : 5.00.9012.1020
DeviceOS : Microsoft Windows NT Workstation 10.0 (Tablet Edition)
IsActive : True
LastActiveTime : 10/1/2020 23:29:34
LastClientCheckTime : 9/8/2020 18:38:10
LastDDR : 9/30/2020 20:29:33
LastHardwareScan : 9/30/2020 22:24:22
LastPolicyRequest : 10/1/2020 23:29:34
Name : DEVICE-LT2
ClientVersion : 5.00.9030.1011
DeviceOS : Microsoft Windows NT Workstation 10.0 (Tablet Edition)
IsActive : True
LastActiveTime : 10/2/2020 00:31:54
LastClientCheckTime : 9/30/2020 23:06:10
LastDDR : 9/30/2020 19:44:46
LastHardwareScan : 9/30/2020 01:15:52
LastPolicyRequest : 10/2/2020 00:31:54
Example 2: Get device resources by collection ID
This command is similar to the first example, but uses the -Resource parameter. When it queries a different class, it returns different properties for similar data.
Name : DEVICE-LT3
ClientVersion : 5.00.9012.1020
OperatingSystemNameandVersion : Microsoft Windows NT Workstation 10.0 (Tablet Edition)
Active : 1
AgentName : {SMS_AD_SYSTEM_DISCOVERY_AGENT, SMS_AD_SECURITY_GROUP_DISCOVERY_AGENT,
MP_ClientRegistration, Heartbeat Discovery}
AgentTime : {2/28/2020 09:45:01, 10/2/2020 01:00:01, 9/21/2020 15:53:47, 9/30/2020 13:29:33}
Name : DEVICE-LT2
ClientVersion : 5.00.9030.1011
OperatingSystemNameandVersion : Microsoft Windows NT Workstation 10.0 (Tablet Edition)
Active : 1
AgentName : {SMS_AD_SYSTEM_DISCOVERY_AGENT, SMS_AD_SECURITY_GROUP_DISCOVERY_AGENT,
MP_ClientRegistration, Heartbeat Discovery}
AgentTime : {2/28/2020 09:45:01, 10/2/2020 01:00:01, 10/1/2020 14:03:56, 9/30/2020 12:44:46}
Example 3: Get properties for a specific device
This command gets a specific device, and pipes the output through the Select-Object cmdlet to show only specific properties. Since it uses the -Resource parameter, the properties are specific to that class.
This command uses the -Fast parameter to get all devices without lazy properties. It filters the list to only devices that aren't clients. It only displays the device name in the final list.
This command shows all devices on which Microsoft Defender has detected a specific threat. It only displays the name of the device.
Get-CMDevice -ThreatName "Trojan:Win32/Wacatac.B!ml" | Select-Object Name
Example 6: Get all devices with any detected malware
This command first uses the Get-CMDetectedMalware cmdlet to get all threats. It then parses through that list, and displays the name of devices with malware.
$allMalware = Get-CMDetectedMalware
foreach ( $malware in $allMalware ) { Get-CMDevice -InputObject $malware | Select-Object Name }
Parameters
-Collection
Use this parameter to get all devices from a device collection object. To get this object, use the Get-CMDeviceCollection cmdlet.
Parameter properties
Type:
IResultObject
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
SearchByValueMandatory
Position:
Named
Mandatory:
True
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-CollectionId
Specify an ID for a device collection. For example, XYZ0004B.
Parameter properties
Type:
String
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
SearchByIdMandatory
Position:
Named
Mandatory:
True
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-CollectionMember
Add this parameter to query the SMS_R_UnknownSystem and SMS_R_System classes for device information. These classes may be restricted by role-based access. These classes contain more detailed machine information.
Parameter properties
Type:
SwitchParameter
Default value:
None
Supports wildcards:
False
DontShow:
False
Aliases:
CollectionMemberInstance
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-CollectionName
Specify the name of a device collection.
Parameter properties
Type:
String
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
SearchByNameMandatory
Position:
Named
Mandatory:
True
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-DisableWildcardHandling
This parameter treats wildcard characters as literal character values. You can't combine it with ForceWildcardHandling.
Parameter properties
Type:
SwitchParameter
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-Fast
Add this parameter to not automatically refresh lazy properties. Lazy properties contain values that are relatively inefficient to retrieve. Getting these properties can cause additional network traffic and decrease cmdlet performance.
If you don't use this parameter, the cmdlet displays a warning. To disable this warning, set $CMPSSuppressFastNotUsedCheck = $true.
Parameter properties
Type:
SwitchParameter
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-ForceWildcardHandling
This parameter processes wildcard characters and may lead to unexpected behavior (not recommended). You can't combine it with DisableWildcardHandling.
Parameter properties
Type:
SwitchParameter
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-InputObject
Specify a detected malware object. To get this object, use the Get-CMDetectedMalware cmdlet.
Parameter properties
Type:
IResultObject
Default value:
None
Supports wildcards:
False
DontShow:
False
Aliases:
Threat
Parameter sets
SearchByValueMandatoryForViewInfectedClients
Position:
Named
Mandatory:
True
Value from pipeline:
True
Value from pipeline by property name:
False
Value from remaining arguments:
False
-Name
Specify the name of a device.
Parameter properties
Type:
String
Default value:
None
Supports wildcards:
True
DontShow:
False
Parameter sets
ByName
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
SearchByValueMandatory
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
SearchByIdMandatory
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
SearchByNameMandatory
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-Resource
Add this parameter to query the SMS_Resource class for device information. This class shouldn't be restricted by role-based access. The output is the same as with the Get-CMResource cmdlet. This output has minimal properties for the device. For more detailed properties, don't add this parameter, or use the CollectionMember parameter.
Parameter properties
Type:
SwitchParameter
Default value:
None
Supports wildcards:
False
DontShow:
False
Aliases:
ResourceInstance
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-ResourceId
Specify the resource ID of a device. For example, 16780010.
Parameter properties
Type:
Int32
Default value:
None
Supports wildcards:
False
DontShow:
False
Aliases:
Id, DeviceId
Parameter sets
ById
Position:
Named
Mandatory:
True
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-ThreatId
Use this parameter to filter the devices that it returns to those devices with specific malware by ID. For example, 2147735505. To get this threat ID, use the Get-CMDetectedMalware cmdlet.
Parameter properties
Type:
String
Default value:
None
Supports wildcards:
False
DontShow:
False
Aliases:
ThreatNameId
Parameter sets
SearchByIdMandatoryForViewInfectedClients
Position:
Named
Mandatory:
True
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-ThreatName
Use this parameter to filter the devices that it returns to those devices with specific malware by name. For example, Trojan:Win32/Wacatac.B!ml. To get this threat name, use the Get-CMDetectedMalware cmdlet.
Parameter properties
Type:
String
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
SearchByNameMandatoryForViewInfectedClients
Position:
Named
Mandatory:
True
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable,
-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see
about_CommonParameters.