The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

franck (17) [Avatar] Offline
#1
Hello All

I don't found how i can read WMI 'Lazy property' in Powershell.

Die SCCM WMI class 'SMS_Collection' haves a 'LAZY' property 'collectionrules[]'.
It return alway a NULL or empty value.

I found some examples in SCCM SDK but only for C# and vbscript, of course.

Is it also possible to read (and write) WMI lazy property in Powershell??

Some help would be greatly appreciated.

Best regards
Franck
marco.shaw (24) [Avatar] Offline
#2
Re: Reading (and writing) WMI 'Lazy Property' with Powershell
I don't have a test environment.

Try something like:
get-wmiobject blah...blah|foreach-object{$_.blah_property}

Let us know. That should help to at least view/read them.
marco.shaw (24) [Avatar] Offline
#3
Re: Reading (and writing) WMI 'Lazy Property' with Powershell
How do I access that class? Is it in the rootsms namespace?

I tried:
PS > get-wmiobject -list -namespace rootsms

But I don't see that class.
franck (17) [Avatar] Offline
#4
Re: Reading (and writing) WMI 'Lazy Property' with Powershell
Hi Marco

This class is in 'rootsmssite_XXX'.

XXX is the site-code

You need an SCCM Site. In our company it's in 'rootsmssite_SBA'
The class 'sms_collection' has a property 'CollectionRule' with qualifier 'lazy'.

See the explanation below 'This property is not returned when you enumerate this class....'

I don't know the Powershell way to make the same as 'SWbemServices.Get' in VBScript.

They are another 'lazy' properties in SMS and I believe in SQL WMI Provider

Thanks a lot for your help

====================================================
Explanations in SCCM 2007 SDK
====================================================

CollectionRules
Data type: SMS_CollectionRule[]
Access type: Read-only
Qualifiers: Lazy
Defines the membership criteria for this collection. You use the SMS_Collection methods to add, update, or delete membership rules. The rules are embedded objects of type SMS_CollectionRuleQuery and SMS_CollectionRuleDirect.

This property is not returned when you enumerate this class. To obtain the collection rules for a collection, you must use IWbemServices::GetObject or SWbemServices.Get.
AgentM (1) [Avatar] Offline
#5
Re: Reading (and writing) WMI 'Lazy Property' with Powershell
does anybody have an answer to this? How can I use Powershell to read lazy properties ?
Barbabob (1) [Avatar] Offline
#6
Re: Reading (and writing) WMI 'Lazy Property' with Powershell
Just in case you're still waiting for an answer... You can get those lazy properties by directly requesting an instance by using:

[WMI]"<WMIpath>"

In my case I wanted to read the lazy properties of a SCCM TaskSequence and used:

[WMI]"\. ootsmssite_xxxSMS_TaskSequencePackage.PackageID='xxx00015'"

There you go smilie

Message was edited by:
Barbabob
franck (17) [Avatar] Offline
#7
Re: Reading (and writing) WMI 'Lazy Property' with Powershell
Hi Barbabob

It doesn't work.

If I type :

[WMI]"\. ootsmssite_cpzSMS_collection.collectionID='SMS00001'"

I get the following Error:

Cannot convert value "\. ootsmssite_cpzSMS_collection.collectionID='SMS00001'"
to type "System.Management.ManagementObject". Error: "Invalid parameter "
At line:1 char:6
+ [WMI]" <<<< \. ootsmssite_cpzSMS_collection.collectionID='SMS00001'"

But this works:

gwmi -name rootsmssite_cpz -cl sms_collection -filter "name='all systems'" | select name, collectionid

name collectionid
---- ------------
All Systems SMS00001

have you an idea ?

I'm thankful for every help and ideas

Best Regards
Franck
franck (17) [Avatar] Offline
#8
Re: Reading (and writing) WMI 'Lazy Property' with Powershell
Hi Barbabob

Are you using PowerShell V2?

I see in a blog an example with PowerShell V2 CTP3.

I'am already using PS 1.0 - on a productive Server :-[

Best Regards
Franck
franck (17) [Avatar] Offline
#9
Re: Reading (and writing) WMI 'Lazy Property' with Powershell
hello all

That's no longer a problem with PS 2.0

Example:

$col = gwmi -comp c007510 -name rootsmssite_cp1 -class sms_collection -filter "Collectionid='CP100298'"
$col

.
.
__SERVER : C007510
__NAMESPACE : rootsmssite_cp1
__PATH : \C007510 ootsmssite_cp1:SMS_Collection.CollectionID="CP100298"
CollectionID : CP100298
CollectionRules : <====================== EMPTY
CollectionVariablesCount : 1
Comment : Important: Read Installation Instructions in the Component Database (Dependences)!
.
.

$col.get() <===== That doesn't works in PowerShell 1.0
$col
.
.
__SERVER : C007510
__NAMESPACE : rootsmssite_cp1
__PATH : \C007510 ootsmssite_cp1:SMS_Collection.CollectionID="CP100298"
CollectionID : CP100298
CollectionRules : {A_Adobe-AfterEffectsCS3_8-0-b01_DE} <===== NO LONGER EMPTY
CollectionVariablesCount : 1
Comment : Important: Read Installation Instructions in the Component Database (Dependences)!
.
.

regards
Franck