widsnet.com
6Oct/110

remote WMI test script

Follow up to http://widsnet.com/2011/10/stop-install-on-uncertified-hardware/
A simple script to test if the user "queryWMIUser" has the required rights to ask WMI questions remote to the site servers.

strTS must be a TS with Driver Packages referenced in it. (Apply Driver Package)
strDriverPackage must be a driver package referenced in the TS.

On Error Resume Next 
strUser = "domain\queryWMIUser"
strPassword = "Password"
strTS = "SMS00001"
strDriverPackage = "SMS00004"

Set objLocator = CreateObject("WbemScripting.SWbemLocator")

For Each strSiteServer In Array("server1", "server2", "server3", "server4", "server5")
	Set objWMIService = objLocator.ConnectServer(strSiteServer, "root\sms", strUser, strPassword)
	Set colItems = objWMIService.ExecQuery("SELECT * FROM SMS_ProviderLocation")
	strErr = "Read Sitecode, Err: " & Err.Number & " " & Err.Description
	For Each objItem in colItems
		strSitecode = objItem.SiteCode
	Next
	WScript.Echo "Server: " & strSiteServer & " " & strSitecode
	WScript.Echo strErr
	Err.Clear
			
	Set objWMIService = objLocator.ConnectServer(strSiteServer, "root\sms\site_" & strSitecode, strUser, strPassword)
	Set colItems = objWMIService.ExecQuery("SELECT * FROM SMS_TaskSequenceReferencesInfo WHERE PackageID='" & strTS & "' AND ReferencePackageID='" & strDriverPackage & "'")
	WScript.Echo "Read TSRefPackage, Err: " & Err.Number & " " & Err.Description
	If colItems.Count = 1 And Err.Number = 0 Then
		WScript.Echo strUser & " has access to read TSRefPackages"
	Else
		WScript.Echo strUser & " has no access to read TSRefPackages"
	End If
	Err.Clear
	
	strSitecode = ""
	WScript.Echo ""
Next
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

No trackbacks yet.