Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - WMI Instances Put Options

Reply
 
Old 11-07-2006   #1 (permalink)
Andrey Nepomnyaschih


 
 

WMI Instances Put Options

Hi,

Is there any way to supply a PutOptions.Type to the Put method of any WMI
Object?

For example, I'm trying to create an Instance of
MSFT_SIPESUserContactGroupData Class.
(msdn.microsoft.com/library/en-us/lcs2005/rtc/msft_sipesusercontactgroupdata.asp?frame=true).

$UserContactGroupDataInstance = (New-Object
System.Management.ManagementClass("MSFT_SIPESUserContactGroupData")).CreateInstance()

$UserContactGroupDataInstance.Name = "Sample Communicator Group"
$UserContactGroupDataInstance.UserInstanceID =
"{701F0848-998F-934B-B207-2F1DE1282190}"

And now I would like to commit it. The MSDN page states that:
For PutInstance operations, only the WBEM_FLAG_CREATE_ONLY and
WBEM_FLAG_UPDATE_ONLY flags are supported.

So, I tried the following way:

$PutOptions = New-Object System.Management.PutOptions
$PutOptions.Type = 2

$UserContactGroupDataInstance.Put($PutOptions)

But, this gives me the following error:
Exception calling "Put" with "1" argument(s): "Exception calling "Put" with
"0" argument(s): "Provider is not capable of the attempted operation ""
At line:1 char:34
+ $UserContactGroupDataInstance.Put( <<<< $PutOptions)

Does anyone have any idea?

Andrey Nepomnyaschih



My System SpecsSystem Spec
Old 11-08-2006   #2 (permalink)
Krishna Vutukuri[MSFT]


 
 

Re: WMI Instances Put Options

Hi Andrey,

Can you try using PsBase to access other overloads of Put() method. V1 of
PowerShell do not expose .net methods of the adapted objects. Put method is
implemented as a script to address some common scenarios. Can you try the
following:

$UserContactGroupDataInstance.PsBase.Put($PutOptions)

Example:

PS C:\Documents and Settings\kriscv> $wmi = gwmi win32_computersystem
PS C:\Documents and Settings\kriscv> $wmi.psbase | gm put | fl


TypeName : System.Management.Automation.PSMemberSet
Name : Put
MemberType : Method
Definition : System.Management.ManagementPath Put(),
System.Management.ManagementPath Put(PutOptions options), System.V
oid Put(ManagementOperationObserver watcher), System.Void
Put(ManagementOperationObserver watcher, PutOpti
ons options)

Thanks
Krishna[MSFT]


"Andrey Nepomnyaschih" <nas@i-free.ru> wrote in message
news:e8FRqXqAHHA.3536@TK2MSFTNGP03.phx.gbl...
> Hi,
>
> Is there any way to supply a PutOptions.Type to the Put method of any WMI
> Object?
>
> For example, I'm trying to create an Instance of
> MSFT_SIPESUserContactGroupData Class.
> (msdn.microsoft.com/library/en-us/lcs2005/rtc/msft_sipesusercontactgroupdata.asp?frame=true).
>
> $UserContactGroupDataInstance = (New-Object
> System.Management.ManagementClass("MSFT_SIPESUserContactGroupData")).CreateInstance()
>
> $UserContactGroupDataInstance.Name = "Sample Communicator Group"
> $UserContactGroupDataInstance.UserInstanceID =
> "{701F0848-998F-934B-B207-2F1DE1282190}"
>
> And now I would like to commit it. The MSDN page states that:
> For PutInstance operations, only the WBEM_FLAG_CREATE_ONLY and
> WBEM_FLAG_UPDATE_ONLY flags are supported.
>
> So, I tried the following way:
>
> $PutOptions = New-Object System.Management.PutOptions
> $PutOptions.Type = 2
>
> $UserContactGroupDataInstance.Put($PutOptions)
>
> But, this gives me the following error:
> Exception calling "Put" with "1" argument(s): "Exception calling "Put"
> with "0" argument(s): "Provider is not capable of the attempted operation
> ""
> At line:1 char:34
> + $UserContactGroupDataInstance.Put( <<<< $PutOptions)
>
> Does anyone have any idea?
>
> Andrey Nepomnyaschih
>
>



My System SpecsSystem Spec
Old 11-08-2006   #3 (permalink)
Andrey Nepomnyaschih


 
 

Re: WMI Instances Put Options

Hello, Krishna.

Yeah, that does work.

Thanks a lot,
Andrey Nepomnyaschih

"Krishna Vutukuri[MSFT]" <kriscv@online.microsoft.com> сообщил/сообщила в
новостях следующее: news:uzoZ722AHHA.3928@TK2MSFTNGP03.phx.gbl...
> Hi Andrey,
>
> Can you try using PsBase to access other overloads of Put() method. V1 of
> PowerShell do not expose .net methods of the adapted objects. Put method
> is implemented as a script to address some common scenarios. Can you try
> the following:
>
> $UserContactGroupDataInstance.PsBase.Put($PutOptions)
>
> Example:
>
> PS C:\Documents and Settings\kriscv> $wmi = gwmi win32_computersystem
> PS C:\Documents and Settings\kriscv> $wmi.psbase | gm put | fl
>
>
> TypeName : System.Management.Automation.PSMemberSet
> Name : Put
> MemberType : Method
> Definition : System.Management.ManagementPath Put(),
> System.Management.ManagementPath Put(PutOptions options), System.V
> oid Put(ManagementOperationObserver watcher), System.Void
> Put(ManagementOperationObserver watcher, PutOpti
> ons options)
>
> Thanks
> Krishna[MSFT]
>
>
> "Andrey Nepomnyaschih" <nas@i-free.ru> wrote in message
> news:e8FRqXqAHHA.3536@TK2MSFTNGP03.phx.gbl...
>> Hi,
>>
>> Is there any way to supply a PutOptions.Type to the Put method of any WMI
>> Object?
>>
>> For example, I'm trying to create an Instance of
>> MSFT_SIPESUserContactGroupData Class.
>> (msdn.microsoft.com/library/en-us/lcs2005/rtc/msft_sipesusercontactgroupdata.asp?frame=true).
>>
>> $UserContactGroupDataInstance = (New-Object
>> System.Management.ManagementClass("MSFT_SIPESUserContactGroupData")).CreateInstance()
>>
>> $UserContactGroupDataInstance.Name = "Sample Communicator Group"
>> $UserContactGroupDataInstance.UserInstanceID =
>> "{701F0848-998F-934B-B207-2F1DE1282190}"
>>
>> And now I would like to commit it. The MSDN page states that:
>> For PutInstance operations, only the WBEM_FLAG_CREATE_ONLY and
>> WBEM_FLAG_UPDATE_ONLY flags are supported.
>>
>> So, I tried the following way:
>>
>> $PutOptions = New-Object System.Management.PutOptions
>> $PutOptions.Type = 2
>>
>> $UserContactGroupDataInstance.Put($PutOptions)
>>
>> But, this gives me the following error:
>> Exception calling "Put" with "1" argument(s): "Exception calling "Put"
>> with "0" argument(s): "Provider is not capable of the attempted operation
>> ""
>> At line:1 char:34
>> + $UserContactGroupDataInstance.Put( <<<< $PutOptions)
>>
>> Does anyone have any idea?
>>
>> Andrey Nepomnyaschih
>>
>>

>
>



My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Vista Desktop Wallpaper Fit options, I thought there were 5 options? General Discussion
2 Instances of IE running Vista General
2 instances of csrss.exe? Vista General
Multiple instances Vista music pictures video


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
╘ Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46