Using Query Results
Building queries
is a great way for administrators to review inventory data, discovery
data, advertisement data, and other site information. You can also use
information in query results to create collections as well as export
data to a text file.
Exporting Query Results to a Text File
Execute the query so the
results display in the results pane. Then right-click the query name and
select View -> Export List. You can then specify to export to
tab-delimited or comma-delimited files. You can also specify to use
Unicode, if required.
Importing and Exporting Queries Between Sites
You
can also import and export queries between sites, and share with your
favorite ConfigMgr administrators. To export a query, right-click the
query object and then select Export Objects. Follow the Export Objects
Wizard, and specify a filename (with an .mof extension) to save the
exported query.
To import a query at the
receiving site, simply right-click the Queries node and select Import
Objects. Follow the prompts in the wizard to complete the import
process.
Creating a Collection Based on Query Results
Collections and queries
both use WQL, making moving from a query to a collection fairly simple.
It is a best practice to create a query to “test” the WQL before
creating a query-based collection. When you create a query, you can
review the values of the attributes that you used for the query
criteria. If you build a collection, you probably will not be able to
see the values of those attributes. So create the query, and verify that
it performs exactly as expected, and then you can copy (or import) that
query into a collection.
To use the WQL from a query in a collection, you must not specify any attributes to display.
Here’s the WQL for this query:
select SMS_R_System.Name, SMS_R_System.ADSiteName,
SMS_G_System_X86_PC_MEMORY.TotalPhysicalMemory,
SMS_G_System_WORKSTATION_STATUS.LastHardwareScan from
SMS_R_System inner join SMS_G_System_X86_PC_MEMORY on
SMS_G_System_X86_PC_MEMORY.ResourceID = SMS_R_System.ResourceId inner join
SMS_G_System_WORKSTATION_STATUS on SMS_G_System_WORKSTATION_STATUS.ResourceID =
SMS_R_System.ResourceId where
SMS_G_System_X86_PC_MEMORY.TotalPhysicalMemory > 2000000
Simply remove all
attributes from the General tab so that only criteria information
remains. Next, click the Show Query Language button to reveal the
updated WQL statement, which appears as follows:
select * from SMS_R_System inner join SMS_G_System_X86_PC_MEMORY on
SMS_G_System_X86_PC_MEMORY.ResourceID = SMS_R_System.ResourceId
inner join SMS_G_System_WORKSTATION_STATUS on
SMS_G_System_WORKSTATION_STATUS.ResourceID = SMS_R_System.ResourceId
where SMS_G_System_X86_PC_MEMORY.TotalPhysicalMemory > 2000000
Finally, paste this new WQL into a query rule for a collection.
Status Message Queries
Use ConfigMgr status
message queries to view information about ConfigMgr components, audit
messages, and changed objects (such as advertisements). Status messages
allow you to see a little deeper into the ConfigMgr site for tasks that
occur on your site. You can create custom status messages, as well as
use one of more than 60 standard status message queries. To view status
message queries, perform the following steps:
1. | Expand Site Database -> System Status and then click Status Message Queries.
|
2. | You will now see all the standard status messages. Simply select a status message, right-click it, and select Show Message.
If the status message query requires additional information, you
will receive a prompt. As an example, execute the All Audit Status
Messages from a Specific Site status message query. You will be prompted
for information, as shown in Figure 1.
|
3. | As shown for the Site Code value in Figure 17.12,
you can directly specify the site code, or you can select the Load
Existing radio button and ConfigMgr will populate the dropdown box with
valid selections. (Use caution when selecting the Load Existing radio
button—if the number of selections is large, such as for computer name,
this process could take several hours!) Specify or select a site code
and then click the Time option. For Time options, you can select an
exact date and time, or you can use the built-in options for 1 hour ago,
12 hours ago, and other intervals.
|
Although the names of the
status message queries are fairly descriptive, it is helpful to point
out several queries that tend to be particularly beneficial when
troubleshooting issues. Table 1 lists some favorite status message queries.
Table 1. Popular Status Message Queries
Query Name | escription |
---|
Advertisements Created, Modified, or Deleted | Allows
you to see advertisement changes in your environment. This status
message query also tells you who performed which operations, as well as
the computer from which the task ran. |
All Status Messages | Returns
every status message reported to the site. Use caution, because this
can be a very large amount of data. It can also be handy in an
“emergency” situation, where you need to quickly see everything that has
changed in the site in the past hour. |
All Audit Status Messages for a Specific Site | For auditing purposes, this displays which user performed what action on the ConfigMgr site. |
Collections Created, Modified, or Deleted | Returns collection modification information, so you can see who deleted/modified what collection, and when. |
Packages, Programs, Advertisements | Each of these status message queries allows you to see changes to each of these ConfigMgr objects. |
You may also want to review the following Microsoft TechCenter articles: