RE: SMS / WMI Scripting questions.

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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


.



Relevant Pages

  • Re: SMS menu options not available on boot?
    ... I'm starting to wonder if the other serial connection that I've got on ... SMS menu options not available on boot? ... That was due to the wrong console ...
    (AIX-L)
  • Re: Remote control over VPN
    ... Make sure the sms client agents are starting up properly when using the vpn ... connection before you try wasting your time connecting to that machine. ... Then, I take it off the LAN, reboot and use RAS/VPN to connect ...
    (microsoft.public.sms.admin)
  • Re: Admin Console Questions
    ... SAP - I meant SMS and yes the ... connection error code is -2147024891 ... > What is the SAP Admin Group you refer to? ...
    (microsoft.public.sms.admin)
  • Re: OSDAgent unable to begin State Restore phase
    ... the connection was not secured. ... Also you'll want to ensure the wireless drivers are available to the OS ... > Bob Mac Neill | SMS OS Deployment ...
    (microsoft.public.sms.tools)
  • Re: ASP - FROM statement slows down connection to database
    ... Open your database in Access, switch to the Queries tab, create a new query ... in Design View without choosing a table, swtich to SQL View, paste the sql ... connection string rather than using an ... recordset open statements. ...
    (microsoft.public.inetserver.asp.db)