Get computer properties in a simple way?

Hi,

I am using the following relevance to get some computer properties, it was created by the Excel creator.
however, is this the best way or i can get these properties in much simple way?

Thanks!

( item 0 of it as string & “$x$” &
item 1 of it as string & “$x$” &
item 2 of it as string & “$x$” &
item 3 of it as string & “$x$” &
item 4 of it as string )
of (
(if (exists result (item 0 of it, item 1 of it) and
exists values of result (item 0 of it, item 1 of it) )
then (concatenation “%0A” of values of result (item 0 of it, item 1 of it))
else ("")),
(if (exists result (item 0 of it, item 2 of it) and
exists values of result (item 0 of it, item 2 of it) )
then (concatenation “%0A” of values of result (item 0 of it, item 2 of it))
else ("")),
(if (exists result (item 0 of it, item 3 of it) and
exists values of result (item 0 of it, item 3 of it) )
then (concatenation “%0A” of values of result (item 0 of it, item 3 of it))
else ("")),
(if (exists result (item 0 of it, item 4 of it) and
exists values of result (item 0 of it, item 4 of it) )
then (concatenation “%0A” of values of result (item 0 of it, item 4 of it))
else ("")),
(if (exists result (item 0 of it, item 5 of it) and
exists values of result (item 0 of it, item 5 of it) )
then (concatenation “%0A” of values of result (item 0 of it, item 5 of it))
else ("")))
of (
bes computers,
bes property “BIOS”,
bes property “Full Operating System Name and Service Pack Level - Windows”,
bes property “Wireless Encryption Status - Windows”,
bes property “Wireless SSID - Windows”,
bes property “Computer Name”)

1 Like

How do you want the output to look like?
Where are you using the results?

I am exporting it to Csv file that should have all computers info with all their data.

There are different forms to get the properties from the BES Computer object.
Using the form above, here is a simplified version that will give you a better sense of what is going on.

(
    values of result (item 0 of it, item 1 of it),
    values of result (item 0 of it, item 2 of it),
    values of result (item 0 of it, item 3 of it)
)
of (
    bes computers,
    bes property "Last Report Time",
    bes property "BIOS",
    bes property "Computer Name"
)

This simple form does not include formatting and error checking provided by the Excel Connector.
Mainly, if any of your computers are not returning any of the properties, you will get an error. If a property (e.g. wireless SSID) returns multiple values, the Excel Connector example concatenates them into a single row.

Thanks - but…

even while using this:

(
values of result (item 0 of it, item 1 of it)
)
of (
bes computers,
bes property “Computer Name”
)

I am getting an error: Singular expression refers to nonexcistent object.

is there a simple way to get the list even if it have blank values?

You might end up working yourself back to the original statement.

Here is another example construct for you.

(
    name of it, 
    values of property results whose (name of property of it = "OS") of it,
    values of property results whose (name of property of it = "IP Address") of it
) 
    of bes computers

The first line “name of it” is possible because the BES Computer object has an attribute call “name”.
Other attributes of BES Computer are “Operating System”, “CPU”, and etc.
However, most properties of BES Computers are not accessed that way. This is where the 2nd form comes in.

I have included “OS” and “IP Address” for you to see the difference. When the results are more than one, you will get multiple lines for your output. If you want to have only one line for one Computer, you can try the following instead.

(
    name of it, 
    values of property results whose (name of property of it = "OS") of it,
    (concatenations of (values of it as string)) of property results whose (name of property of it = "IP Address") of it
) 
    of bes computers
1 Like

This is excellent. I don’t think I’ve ever tried it this way before in production. It seems like it might be more efficient.

Related:

2 Likes