0
votes

I am trying to write a script to pull software list down from multiple computers in one script, however most is working but one field is not pulling through anything

I have got this script below...

GET-WMIOBJECT -CLASS WIN32_PRODUCT -COMPUTER CLUKxxx,CLUKyyy,CLUKzzz | SELECT-OBJECT COMPUTERNAME, NAME, VERSION, VENDOR | SORT OBJECTNAME | EXPORT-CSV "C:\CLUKxxx_yyy_zzz_Programs.csv"

the name, version and vendor is pulling through just fine, however I cannot seem to find a way to pull through the computer name. I have tried _SERVER, COMPUTER, COMPUTERNAME, SERVER but nothing is working.

I know the script is working pulling through software from both computers as I got duplicate program names in the list (i.e. IBM Notes comes up twice).

Does anyone know how I can put the computer name in the script?

So far, COMPUTERNAME column is appearing blank.

Thanks guys. Dan

1
Have you used Foreach-Object before? This would still pull back duplicate programs for each machine that has them installed on, but you can then easily separate the results per machine at least.Ross Lyons
Hi ross, I haven't actually used that before. How can work that within my script?Dan Goodwin

1 Answers

0
votes

Use the PsComputerName property of WMI objects. Change your script to -

GET-WMIOBJECT -CLASS WIN32_PRODUCT -COMPUTER CLUKxxx,CLUKyyy,CLUKzzz | SELECT-OBJECT PsCOMPUTERNAME, NAME, VERSION, VENDOR