#93083 - 2003-10-08 11:52 PM
Problem updating the properties of a new SWbemLocator object.
|
Anonymous
Anonymous
Unregistered
|
I'm trying to convert the following VB code to KIX. It's actually to automate the creation of a SMS package within SMS 2.0 but I'm guessing it would apply anywhere:
code:
Set objWbemLocator = CreateObject("WbemScripting.SWbemLocator") Set SMSConnection = objWbemLocator.ConnectServer("SERVERNAME","Root\sms\site_XXX")
Set instPackage = SMSConnection.Get("SMS_Package").SpawnInstance_
instPackage.Description = "Office 2000 installation" instPackage.Manufacturer = "Microsoft" instPackage.Name = "Office 2000"
instPackage.Put_ 0, SMSContext
I've got this far, but I can't work out what I'm doing wrong with the PUT_
code:
$oWBEMLoc=CreateObject("WbemScripting.SWbemLocator") $oWBEMSrv=$oWBEMLoc.ConnectServer("SERVERNAME", "root\SMS\site_XXX") $oNewPackage=$oWBEMSrv.Get("SMS_Package").SpawnInstance_
$oNewPackage.Description = "Office 2000 installation" $oNewPackage.Manufacturer = "Microsoft" $oNewPackage.Name = "Office 2000"
$=$oNewPackage.Put_(0, "SMSContext")
Can anyone point out where I'm going wrong - it's stumped me ;-(
|
|
Top
|
|
|
|
#93084 - 2003-10-09 02:08 AM
Re: Problem updating the properties of a new SWbemLocator object.
|
SpongeBobSquarePants
Lurker
Registered: 2002-03-24
Posts: 3
Loc: UnderSea
|
Hope this isn't a dumb question, but did you post the entire script, is there a
Set SMSContext = ...
kicking around in there somewhere ?
-Bob [ 09. October 2003, 02:12: Message edited by: SpongeBobSquarePants ]
|
|
Top
|
|
|
|
#93086 - 2003-10-09 03:35 PM
Re: Problem updating the properties of a new SWbemLocator object.
|
Anonymous
Anonymous
Unregistered
|
No, I couldn't work out from where that came. The original script is actually full VB - see the following link from MSDN: Creating a Package and Programs Using SMS Classes
I looked a little closer at PUT_ SWbemObject.Put_ and it talks about this either being blank, or being a value name from a provider that is servicing this request.
It *seems* to work without the rest of the PUT_
code:
$=$oNewPackage.Put_
but I wonder if it's not actually really doing what I ask it to...
|
|
Top
|
|
|
|
#93088 - 2003-11-04 01:52 AM
Re: Problem updating the properties of a new SWbemLocator object.
|
Anonymous
Anonymous
Unregistered
|
OK so you were right, the constant was missing.
This is the line of code I missed off:
code:
Dim SMSContext As New SWbemNamedValueSet SMSContext.Add "LocaleID", "MS\1033" SMSContext.Add "MachineName", "MyMachine" SMSContext.Add "ApplicationName", "MyApp"
How would I create an array as SWbemNamedValueSet and add my own values?
Thanks in advance
|
|
Top
|
|
|
|
#93089 - 2003-11-04 02:10 AM
Re: Problem updating the properties of a new SWbemLocator object.
|
SpongeBobSquarePants
Lurker
Registered: 2002-03-24
Posts: 3
Loc: UnderSea
|
To create your contexts, how about:
$SMSContext = CreateObject("WbemScripting.SWbemNamedValueSet")
$SMSContext.Add("LocaleID", "MS\1033") $SMSContext.Add("MachineName", "MyMachine") $SMSContext.Add("ApplicationName", "MyApp")
Just a wild quess from the spongster.
|
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 2220 anonymous users online.
|
|
|