RE: SMS / WMI Scripting questions.
- From: RobM <RobM@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 2 May 2006 02:27:03 -0700
I'd raise the SMS Site object when needed, perform the query and if no joy
then null the connection (set whatever = nothing) and wscript.delay for a few
minutes, wake up, raise the SMS site object again and perform the query,
repeat ... i'm sure there is a more elegant approach out there :>
See
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/smssdk03/hh/sms/usingsms_2skl.asp
for more info about impersonation levels when connection to the SMS Site
object.
--
Rob - Windows Management User Group
www.wmug.co.uk
"Ward" wrote:
Hi,.
First big appologies - for the long message only
way to describe the issues I am having ;)
1. SMS Provider Database / buffering.
Ok here goes - I am making a simple routine in VBScript to
wait for a machine to be discovered into the SMS database.
A long the lines of keep looping around until the record
apears then continue (see code below).
Now to try to be efficient I want to have a global object
which maintains the connection to the SMS Provide on the site
server. then I just keep working from that. My concern is
that if the resource is not in the SMS database then it will
keep looping forever. (What I really have todo is close the
connection then re-establish it and do the query again). In
other words it might buffer the data so if it is not there
when I make the initial query it will not be there until I close
the connection. Is this a valid concern or will this approach
be ok. BTW - I welcome better ways of doing this if there are
any.
Here is a code fragment
' --------------------------------
dim pcname,ResourceID
dim pc_found
' sms_services -> existing connection to SMS database
' defined as public elsewhere.
dim pcname
dim pc_found
pcname = "PC1" ' Machine to look for.
pc_found = false ' Flag set to true when machine found.
do while pc_found = false
wql = "Select * from SMS_R_System where Name ='" + pcname + "'"
Set Machines = sms_services.ExecQuery(wql)
For Each Machine In Machines
pc_found = True
Next
wscript.sleep 500
Loop
' --------------------------------
2. Connecting to the SMS namespace.
I want to make a connection to the SMS NameSpace ok since
I want to connect as a Local Administrator I realise I need
to connect by doing something
Set sms_services = objSWbemLocator.ConnectServer _
(sms_server, "root\sms",sms_domain+"\"+sms_username,sms_password)
Quetion is do I need to set the impersonation level some way or
is providing the credentionals ok.
3. Closing the connection.
Now I assume that the SMS connection will be close when varibales
go out of scope is there another way.
e.g.
set sms_services = nothing
will that do the trick and close the connection or is there
some command that is the opposite of ConnectServer..?
Thanks in advance,
Ward
- References:
- SMS / WMI Scripting questions.
- From: Ward
- SMS / WMI Scripting questions.
- Prev by Date: New Distribution Point Share
- Next by Date: RE: Basic Client Questions
- Previous by thread: SMS / WMI Scripting questions.
- Next by thread: Re: Server reboots
- Index(es):
Relevant Pages
|