rod has asked for the wisdom of the Perl Monks concerning the following question:
I use Perl to interrogate our SMS database via WMI quite a bit. On this occasion, I want to extract the count of items in a table but can't get Perl to reveal the results!
We start with the normal connection to WMI...
If I then submit a "straight" query...# Connect to WMI on reporting server # my $SWbemLocator = Win32::OLE->new("WbemScripting.SWbemLocator") or FatalCOMError("Can't open WbemScripting object"); my $SWbemServices = $SWbemLocator->ConnectServer($Server, "root/sms/si +te_$SiteCode") or FatalCOMError("Can't connect to server: $Server");
...$count contains the count of items in the collection. Unfortunately, on a large collection, this can be a bit slow. Ideally, I'd use the count(*) WQL command like so;# Get count of clients in collection my $WQL = q/select * from SMS_CM_RES_COLL_CEN01562/; $Colln = $SWbemServices->ExecQuery($WQL,"WQL",16) or FatalErr("Exe +cQuery for Clients failed",1); $count = $Colln->{Count};
The problem that I have with this code is that, no matter what I try, I can't get to the actual result!# Get count of clients in collection my $WQL = q/select count(*) from SMS_CM_RES_COLL_CEN01562/; $Colln = $SWbemServices->ExecQuery($WQL,"WQL",16) or FatalErr("Exe +cQuery for Clients failed",1);
If I try the same query on WbemTest, I get a single-line answer that shows the correct answer. How do I get to it in Perl?
Can anyone help?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Extracting WQL "count" results
by john_oshea (Priest) on Jul 05, 2006 at 17:02 UTC | |
Re: Extracting WQL "count" results
by Moron (Curate) on Jul 05, 2006 at 15:06 UTC | |
by john_oshea (Priest) on Jul 05, 2006 at 17:20 UTC | |
by Moron (Curate) on Jul 06, 2006 at 09:28 UTC | |
Re: Extracting WQL "count" results
by Moron (Curate) on Jul 06, 2006 at 09:35 UTC | |
by mjg (Scribe) on Jul 06, 2006 at 17:16 UTC | |
by Moron (Curate) on Jul 07, 2006 at 08:58 UTC | |
Re: Extracting WQL "count" results
by mjg (Scribe) on Jul 06, 2006 at 17:14 UTC | |
by maa (Pilgrim) on Jul 07, 2006 at 20:51 UTC | |
A reply falls below the community's threshold of quality. You may see it by logging in. |
Back to
Seekers of Perl Wisdom