Get-CMCollectionMember
Get members of a device or user collection.
Syntax
Get-CMCollectionMember
-CollectionName <String>
[-Name <String>]
[-ResourceId <Int32>]
[-SmsId <String>]
[-DisableWildcardHandling]
[-ForceWildcardHandling]
[<CommonParameters>]
Get-CMCollectionMember
-CollectionId <String>
[-Name <String>]
[-ResourceId <Int32>]
[-SmsId <String>]
[-DisableWildcardHandling]
[-ForceWildcardHandling]
[<CommonParameters>]
Get-CMCollectionMember
-InputObject <IResultObject>
[-Name <String>]
[-ResourceId <Int32>]
[-SmsId <String>]
[-DisableWildcardHandling]
[-ForceWildcardHandling]
[<CommonParameters>]
Description
Use this cmdlet to get members of a collection. Collections can include devices or users, but not both. When you query a collection, this cmdlet returns objects for all members.
For more information, see Introduction to collections in Configuration Manager.
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 a member of a collection by using the pipeline operator
This command first uses the Get-CMCollection cmdlet to get the collection object named UserCol1. It then uses the pipeline operator to pass the object to Get-CMCollectionMember, which gets all members in the collection. Finally, this example uses the Select-Object cmdlet to only display the member names.
Get-CMCollection -Name "UserCol1" | Get-CMCollectionMember | Select-Object Name
Example 2: Get a member of a collection by name
This command queries the collection DeviceCol1 for members that have a name beginning with domain
. The asterisk (*
) wildcard matches multiple characters. So results can include names such as "domain1" or "domain-controller".
Get-CMCollectionMember -CollectionName "DeviceCol1" -Name "domain*"
Example 3: Export collection details to a CSV
This example queries the XYZ0004B device collection for a set of properties and stores that in the variable, $collMem. The second line converts that data into comma-separated value (CSV) format, and outputs to a file.
$collMem = Get-CMCollectionMember -CollectionId "XYZ0004B" | Select-Object Name,Domain,LastLogonUser,DeviceOS,DeviceOSBuild,MACAddress,SerialNumber
$collMem | ConvertTo-Csv -NoTypeInformation | Out-File -FilePath "C:\output\XYZ0004B.csv"
Parameters
-CollectionId
Specify the ID of a collection to query. For example, "XYZ0004B"
.
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-CollectionName
Specify the name of a collection to query.
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-DisableWildcardHandling
This parameter treats wildcard characters as literal character values. You can't combine it with ForceWildcardHandling.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-ForceWildcardHandling
This parameter processes wildcard characters and may lead to unexpected behavior (not recommended). You can't combine it with DisableWildcardHandling.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-InputObject
Specify a collection object to query. To get a collection object, use one of the following cmdlets:
You can also use the pipeline operator (|
) to pass a collection object to Get-CMCollectionMemeber on the command line.
Type: | IResultObject |
Aliases: | Collection |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-Name
To filter the results, specify the name of a resource in the collection. This filter isn't case-sensitive.
You can use wildcard characters:
*
: Multiple characters?
: Single character
Type: | String |
Aliases: | ResourceName |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | True |
-ResourceId
To filter the results, specify a resource ID. For example, 16777242
. The cmdlet only returns a record for that resource in the targeted collection.
Type: | Int32 |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-SmsId
To filter the results, specify the SMSID of a resource. For example, "GUID:7a186367-7372-4841-889e-ba2e3aad1e85"
. This filter isn't case-sensitive.
You can use wildcard characters:
*
: Multiple characters?
: Single character
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | True |
Inputs
Microsoft.ConfigurationManagement.ManagementProvider.IResultObject
Outputs
System.Object