Windows Scripting BLOG

Due to limited time working on this project this place is not intended to people who are new to scripting but much more for people who are already familiar with the VBS/WMI syntax.

Dienstag, 22. Mai 2007

Refreshing SMS 2003-Site Client membership

on error resume next

Sub SMSChk
on error resume next

set comp = CreateObject ("Microsoft.SMS.Client")
if err.number <> 0 then
wscript.echo "SMS Advanced Client not present. Cannot continue."
exit Sub
end if

site = comp.GetAssignedSite


if err.number <> 0 then

err.clear
site = comp.AutoDiscoverSite

if err.number <> 0 then
Wscript.Echo "Could not Discover Site. Please use smscheck.vbs to assign a site manually"
exit Sub
else

comp.setAssignedSite(site)
SiteGet = comp.GetAssignedSite
if err.number <> 0 then
Wscript.Echo "Error setting Site. Please try again."
Exit Sub
else
Wscript.Echo "Client is now assigned to site " & SiteGet
End if
end if
else
WScript.echo "Client currently assigned to site " & site & " !Please use smscheck.vbs to assign a site manually (if needed)"
end if
err.clear
end sub

if Wscript.Arguments.count > 0 then
inp = Wscript.Arguments(0)
set comp = CreateObject ("Microsoft.SMS.Client")
if err.number <> 0 then
wscript.echo "SMS Advanced Client not present. Cannot continue."
WScript.quit
end if
err.clear
comp.setAssignedSite(inp)
SiteGet = comp.GetAssignedSite
if err.number <> 0 then
Wscript.Echo "Error setting Site. Please try again."
err.clear
else
Wscript.Echo "Client is now assigned to site " & SiteGet
end if
else
call SMSChk()
end if


' Julian Ruf 07.04.2006 julian.ruf@ecb.int

Keine Kommentare: