Friday, February 10, 2012 5:29 PM
Hello. My environment is SCCM 2007 SP2. I have several secondary servers that have a server share setup as standard DPs. I want to refresh the package on these DPs via a script. I have used the below script before on SMS 2003 DPs. However, I get an error connecting to the root\sms namespace on one of the SCCM 2007 DPs. Does anyone know what namespace I would connect to to refresh the package on these DPs?
Thank you for the assistance.
strSMSServer = <SMSServer>
strPackageID = <<PackageID>>
StrSiteCode = <<SiteCode>>
Set objLoc = CreateObject("WbemScripting.SWbemLocator")
Set objSMS= objLoc.ConnectServer(strSMSServer, "root\sms")
Set Results = objSMS.ExecQuery _
("SELECT * From SMS_ProviderLocation WHERE ProviderForLocalSite = true")
For each Loc in Results
If Loc.ProviderForLocalSite = True Then
Set objSMS = objLoc.ConnectServer(Loc.Machine, "root\sms\site_" & _
strSMSSiteCode = Loc.SiteCode
Set DPs = objSMS.ExecQuery _
("Select * From SMS_DistributionPoint " & _
"WHERE SiteCode='" & strSiteCode & _
"' AND PackageID='" & strPackageID & "'")
For Each DP In DPs
DP.RefreshNow = True
Friday, February 10, 2012 5:50 PM
Here is the code listing from SCCM 2007 SDK for listing the Distribution Points for the site. You don't mention what error that you are getting, but you may find it helpful.
Sub ListDistributionPointsForSite(connection, siteCode) ' This query selects all distribution points for a site based on the provided site code. Query = "SELECT * FROM SMS_SystemResourceList WHERE RoleName='SMS Distribution Point' AND SiteCode='" & siteCode & "'" ' Run query, which populates listOfResources with a collection of objects. Set ListOfResources = connection.ExecQuery(query, , wbemFlagForwardOnly Or wbemFlagReturnImmediately) ' Output header for list of distribution points. Wscript.Echo "List of distribution points for site: " & siteCode Wscript.Echo "--------------------------------------------" ' Enumerate through the collection of objects returned by the query. For Each resource In listOfResources ' Output the server name for each distribution point. Wscript.Echo resource.ServerName Next End Sub
It would be greatly appreciated if you would mark any helpful entries as helpful and if the entry answers your question, please mark it with the Answer link.
Friday, February 10, 2012 7:13 PMI am getting an error connecting to the root\sms namespace on the secondary server. My assumption is that I should be either be connecting to a different namespace.
Friday, February 10, 2012 7:21 PM
I found it. Below is a link to the WMI namespaces for SCCM 2007.
- Marked As Answer by Lorrec Friday, February 10, 2012 7:21 PM