1/28/2009

vbScript to validate SMS/SCCM Sourcepaths

This Script will check the Sourcepath for each package in SMS or SCCM if it is valid.

Siteserver = InputBox("Please enter the name of the SMS/SCCM Site Server")
Sitecode = InputBox("Please enter the Site Code of the SMS/SCCM Site")

Dim objFSO: Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objFile : Set objFile = objFSO.CreateTextFile("ValidatePkgSourcePath.log")
Dim objSWbemLocator : Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Dim objSWbemServices : Set objSWbemServices = objSWbemLocator.ConnectServer (Siteserver, "root\sms\site_" + Sitecode)

Set colPackages=objSWbemServices.ExecQuery("SELECT * FROM SMS_Package")

For Each objPackage In colPackages
strPackageName = objPackage.Manufacturer &" " &objPackage.Name &" " &objPackage.Version &" " &objPackage.Language
If objPackage.PkgSourcepath = "" Then
objFile.WriteLine strPackageName &" - Sourcepath is empty"
End If
If Not objFSO.FolderExists(objPackage.PkgSourcepath) Then
objFile.WriteLine strPackageName &" - Sourcepath is not valid (" &objPackage.PkgSourcepath &")"
End If
Next
WScript.Echo "Finished"

No comments: