Showing posts with label queries. Show all posts
Showing posts with label queries. Show all posts

Tuesday, March 18, 2014

Howto: Create a device collection based on manufacturer in SCCM 2012

In this blog we'll discuss how to create a device collection in SCCM based on a device manufacturer.
This can be usefull when targeting hardware specific applications for instance.

First off, we'll need to get the manufacturer as it is noted in WMI. In our example, we used an ASUS.

The command you can run in the command prompt is:

wmic computersystem get manufacturer

 As you can see the return value is : ASUSTek COMPUTER INC.
 Next, we'll create a new device collection in the SCCM Console.
 Give it an appropriate name and optionally comment it. Choose 'All Systems' as the limiting collection. Click Next.
 Choose for 'Add Rule' and click on 'Query Rule'.
 Give the query a recognizable name, and click on 'Edit Query Statement...'
 Go to the Criteria tab, and click on 'Show Query Language'.
 Paste in the following code:

select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM on SMS_G_System_COMPUTER_SYSTEM.ResourceId = SMS_R_System.ResourceId where SMS_G_System_COMPUTER_SYSTEM.Manufacturer = "ASUSTeK COMPUTER INC."

Notice the last line, where the manufacturer comes in.

Click Next and finish the wizard.
Then rightclick the collection and choose 'Update Membership'. 
After refreshing the console, you'll notice that it's populated with ASUS devices.
















Friday, February 21, 2014

Monitoring Deployments in SCCM 2012 R2

 

Monitoring Deployments in SCCM 2012 R2

If you are running in to problems with your Task Sequence deployments in SCCM, it is nice to have a central view of the errors, rather than looking in the local log files of the client.

This can be achieved by using Status Message Queries.

At first you will need to get the Deployment ID of the task sequence:

Then navigate to the status message queries section in your SCCM console:

Monitoring -> Overview -> System Status -> Status Message Queries, and click Create Status Message Query.

Give your query a name (include your Task Sequence name if you like), and click 'Edit Query Statement'.


Then click on 'Show Query Language'
Copy the following Query into the Query Statement, and click OK.

Replace the site code (P01) and the Deployment ID (P012002A), in the query with your own data.
select stat.*, ins.*, att1.*, att1.AttributeTime from SMS_StatusMessage as stat left join SMS_StatMsgInsStrings as ins on stat.RecordID = ins.RecordID left join SMS_StatMsgAttributes as att1 on stat.RecordID = att1.RecordID inner join SMS_StatMsgAttributes as att2 on stat.RecordID = att2.RecordID where att2.AttributeID = 401 and att2.AttributeValue = "P01200ED" and stat.SiteCode = "P01" and att2.AttributeTime >= ##PRM:SMS_StatMsgAttributes.AttributeTime## order by att1.AttributeTime desc


 


Click OK and finish the wizard.
Now we can try and run the query.

Rightclick the query, and click on Show Messages.
You'll get a question to fill in a time span:
 




Click OK.
You should see something like this:



 
Now you can doubleclick any message to see its details.

Happy troubleshooting!