Jump to content


fr43nk

SCCM 2012 - Collection WQL Query

Recommended Posts

Hello.

I want to buil a collection, that contains all clients with a certain MS Office 2010 Patch installed.

I think that a membership rule with a wql query is the way i have to go.

 

Thats what I got so far:

 

select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYS TEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_PatchStatusEx on SMS_G_System_PatchStatusEx.ResourceID = SMS_R_System.ResourceId where SMS_G_System_PatchStatusEx.ID = "MS12-060" and SMS_G_System_PatchStatusEx.LastStateName = "Installed"

 

Is SMS_G_System_PatchStatusEx the place I have to look ?

 

Can somebody help me with that ?

 

Sincerely,

frank

Share this post


Link to post
Share on other sites

thank your for the hint.

but its still not working

 

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_CI_ComplianceState on SMS_G_System_CI_ComplianceState.ResourceID = SMS_R_System.ResourceID WHERE SMS_G_System_CI_ComplianceState.CI_UniqueID = "49696650-4242-42d5-931d-fb097c1f786e" AND SMS_G_System_CI_ComplianceState.IsDetected = 1

 

at least i dont have syntax errors :)

Share this post


Link to post
Share on other sites

cause no clients are listed, and i know for sure that 8 clients have that patch already installed

 

when i run this powershell script on those clients, they get in the right collection - that i cant use that script is a different story :)

 

# Sammlung, Computername und Patch definieren

$SiteName="P01"

$SCCMServer="server.domain.xxx"

$SCCMNameSpace="root\sms\site_$SiteName"

$SCCMCollectionID = "P010004C"

$ComputerToAdd = get-content env:computername

$Patch = "KB2597986"

# fügt den Computer zur Sammlung per Directer Regel

FUNCTION AddToCollection{

$computer = gwmi -computer $SCCMServer -namespace $SCCMNameSpace -Query "select * from SMS_R_System where NetBiosName='$ComputerToAdd'"

$SCCMCollection=[WMI]"\\$($SCCMServer)\$($SCCMNameSpace):SMS_Collection.CollectionID='$SCCMCollectionID'"

$ruleClass = [wmiclass]"\\$($SCCMServer)\$($SCCMNameSpace):SMS_CollectionRuleDirect"

$newRule = $ruleClass.CreateInstance()

$newRule.RuleName = $ComputerToAdd

$newRule.ResourceClassName = "SMS_R_System"

$newRule.ResourceID = $computer.ResourceID

$null = $SCCMCollection.AddMembershipRule($newRule)

}

 

#überprüfen ob Update MS12-060 (KB2720573) installiert ist und ggf. Funktion ausführen

$PatchSession = New-Object -ComObject Microsoft.Update.Session

$PatchSearcher = $PatchSession.CreateUpdateSearcher()

$PatchSearcher.QueryHistory(0, $PatchSearcher.GetTotalHistoryCount()) | Where-Object {$_.Title -match $Patch} |

ForEach-Object {

AddToCollection

}

Share this post


Link to post
Share on other sites

Thank you very much for your hints, you helped me to solve the problem and even to do more

than i expected.

I wasnt aware of the meaning of DCM, but now that i did some research, the whole stuff makes sense.

I created Configuration Items and Baselines, and now i am able to do wql queries like i planed.

 

Best regards,

fr43nk

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.