description | external help file | Module Name | ms.date | schema | title |
---|---|---|---|---|---|
Configure a Configuration Manager query. |
AdminUI.PS.dll-Help.xml |
ConfigurationManager |
12/29/2020 |
2.0.0 |
Set-CMQuery |
Configure a Configuration Manager query.
Set-CMQuery [-Comment <String>] [-Expression <String>] -InputObject <IResultObject>
[-LimitToCollectionId <String>] [-NewName <String>] [-PassThru] [-TargetClassName <String>]
[-DisableWildcardHandling] [-ForceWildcardHandling] [-WhatIf] [-Confirm] [<CommonParameters>]
Set-CMQuery [-Comment <String>] [-Expression <String>] -Id <String> [-LimitToCollectionId <String>]
[-NewName <String>] [-PassThru] [-TargetClassName <String>] [-DisableWildcardHandling]
[-ForceWildcardHandling] [-WhatIf] [-Confirm] [<CommonParameters>]
Set-CMQuery [-Comment <String>] [-Expression <String>] [-LimitToCollectionId <String>] -Name <String>
[-NewName <String>] [-PassThru] [-TargetClassName <String>] [-DisableWildcardHandling]
[-ForceWildcardHandling] [-WhatIf] [-Confirm] [<CommonParameters>]
Use this cmdlet to configure a query in Configuration Manager. Configuration Manager queries define a WMI Query Language (WQL) expression to get information from the site database based on the criteria you provide. WQL is similar to SQL, but still goes through the SMS Provider instead of directly to the database. So WQL still abides by your role-based access configuration.
Queries can return most types of Configuration Manager objects, which include computers, sites, collections, applications, and inventory data. For more information, see Introduction to queries in Configuration Manager.
By default, Configuration Manager includes several queries. You can use the Get-CMQuery cmdlet to review the default queries. For more examples of WQL expressions, see Example WQL queries.
Note
Run Configuration Manager cmdlets from the Configuration Manager site drive, for example PS XYZ:\>
. For more information, see getting started.
Get-CMQuery -Name "My systems" | Set-CMQuery -NewName "My systems v2"
Set-CMQuery -Name "Windows 10" -LimitToCollectionId "<Prompt>"
Specify an optional comment to further identify the query in the site.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This parameter treats wildcard characters as literal character values. You can't combine it with ForceWildcardHandling.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specify the WQL statement that defines the attributes to display in the results and the criteria to limit the results.
WQL statements often include double quotation marks ("
), so set this parameter's value as a string enclosed in single quotation marks ('
).
For more examples, see Example WQL queries.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This parameter processes wildcard characters and may lead to unexpected behavior (not recommended). You can't combine it with DisableWildcardHandling.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specify the ID of the query to configure. For example, "XYZ00006"
.
Type: String
Parameter Sets: SearchByIdMandatory
Aliases: QueryId
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specify a query object to configure. To get this object, use the Get-CMQuery cmdlet.
Type: IResultObject
Parameter Sets: SearchByValueMandatory
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
Specify how to configure collection limiting for this query:
- Not collection limited: Set this parameter's value to a blank string (
""
). Don't use the$null
built-in variable. - Limit to collection: Specify the ID of a collection. For example,
"SMSDM003"
for the All Desktop and Server Clients collection. - Prompt for collection: Set this parameter's value to
"<Prompt>"
.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specify the name of the query to configure.
Type: String
Parameter Sets: SearchByNameMandatory
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specify a new name to rename the query.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Add this parameter to return an object that represents the item with which you're working. By default, this cmdlet may not generate any output.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specify the name of the object class that you want the query to return. There are many object types available. The following table lists several common class names with the description from the Configuration Manager console:
Class name | Description |
---|---|
SMS_R_System |
System resource |
SMS_Program |
Program |
SMS_R_UserGroup |
User group resource |
SMS_R_User |
User resource |
SMS_SiteAndSubsites |
Site and subsites |
SMS_R_UnknownSystem |
Unknown computer |
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Prompts you for confirmation before running the cmdlet.
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Shows what would happen if the cmdlet runs. The cmdlet doesn't run.
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Export-CMQuery Get-CMQuery Import-CMQuery Invoke-CMQuery New-CMQuery Remove-CMQuery Introduction to queries in Configuration Manager