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 |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Prompts you for confirmation before running the cmdlet.
Type: | SwitchParameter |
Aliases: | cf |
Position: | Named |
Default value: | None |
Required: | False |
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 |
Position: | Named |
Default value: | None |
Required: | False |
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 |
Position: | Named |
Default value: | None |
Required: | False |
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 |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specify the ID of the query to configure. For example, "XYZ00006"
.
Type: | String |
Aliases: | QueryId |
Position: | Named |
Default value: | None |
Required: | True |
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 |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
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 |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specify the name of the query to configure.
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specify a new name to rename the query.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
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 |
Position: | Named |
Default value: | None |
Required: | False |
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 |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Shows what would happen if the cmdlet runs. The cmdlet doesn't run.
Type: | SwitchParameter |
Aliases: | wi |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Microsoft.ConfigurationManagement.ManagementProvider.IResultObject
System.Object