This script will refresh the packages given in text file listofpackagesToRefresh.txt to that DP
Option Explicit
On Error Resume Next
Dim objFSO
Dim objTextFile
Dim strNextLine
Dim arrServiceList
Dim WbemServices
Dim loc
Set loc = CreateObject("WbemScripting.SWbemLocator")
Set WbemServices = loc.ConnectServer( , "root\SMS\site_xxx")
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("E:\DWM Tools\Scripts\listofpackagesToRefresh.txt", ForReading)
Do Until objTextFile.AtEndOfStream
'read the next line
strNextLine = objTextFile.Readline
arrServiceList = Split(strNextLine , " ")
'arrServiceList(0) = packageid, arrServiceList(1) = DP
Wscript.Echo "packageID: " & arrServiceList(0)
Wscript.Echo "DP : " & arrServiceList(1)
Set DPs = wbemServices.ExecQuery("Select * From SMS_DistributionPoint WHERE PackageID='" & arrServiceList(0) & "' AND SiteCode = '" & arrServiceList(1) & "'")
For Each DP In DPs
Wscript.Echo " Refreshing : " & DP.SiteName
'DP.RefreshNow = True
DP.Put_
Next
Loop
Option Explicit
On Error Resume Next
Dim objFSO
Dim objTextFile
Dim strNextLine
Dim arrServiceList
Dim WbemServices
Dim loc
Set loc = CreateObject("WbemScripting.SWbemLocator")
Set WbemServices = loc.ConnectServer( , "root\SMS\site_xxx")
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("E:\DWM Tools\Scripts\listofpackagesToRefresh.txt", ForReading)
Do Until objTextFile.AtEndOfStream
'read the next line
strNextLine = objTextFile.Readline
arrServiceList = Split(strNextLine , " ")
'arrServiceList(0) = packageid, arrServiceList(1) = DP
Wscript.Echo "packageID: " & arrServiceList(0)
Wscript.Echo "DP : " & arrServiceList(1)
Set DPs = wbemServices.ExecQuery("Select * From SMS_DistributionPoint WHERE PackageID='" & arrServiceList(0) & "' AND SiteCode = '" & arrServiceList(1) & "'")
For Each DP In DPs
Wscript.Echo " Refreshing : " & DP.SiteName
'DP.RefreshNow = True
DP.Put_
Next
Loop
No comments:
Post a Comment