By Request Connecting Vbs To An SMS Site Server

 

There are several different ways to connect to an SMS site server using Vbs. The two most common examples are shown below. The first one uses an input box to prompt you to enter the site server name and the site code. The final script hard codes the variables and all you need to do is specify the site server and site code.

 

By Input Box: Prompt

 

strSiteServer = InputBox("Site Server Name")

strSiteCode = InputBox("Site Code")

Set objSWbemServices = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _

& strSiteServer & "\root\sms\site_" & strSiteCode)

If Err.Number <> 0 Then

Wscript.Echo "The Connection Failed"

Else

Wscript.Echo "Connection Established"

End If

Wscript.Quit

 

Hard Coded:

 

strSiteServer = "Site_Server"

strSiteCode = "Site_Code"

Set objSWbemServices = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _

& strSiteServer & "\root\sms\site_" & strSiteCode)

If Err.Number <> 0 Then

Wscript.Echo "The Connection Failed"

Else

Wscript.Echo "Connection Established"

End If

Wscript.Quit

 

Published Wednesday, September 27, 2006 2:56 PM by dhite
Filed under:

Comments

No Comments