0

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

2
  • 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. Commented May 16, 2018 at 11:03
  • Hi ross, I haven't actually used that before. How can work that within my script? Commented May 16, 2018 at 11:05

1 Answer 1

0

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
Sign up to request clarification or add additional context in comments.

2 Comments

Hello, thanks for your help but the column is still coming up blank when I export to .csv
It works fine for me. Are you getting the Computer name on console for the command GET-WMIOBJECT -CLASS WIN32_PRODUCT -COMPUTER CLUKxxx,CLUKyyy,CLUKzzz | SELECT-OBJECT PsCOMPUTERNAME, NAME, VERSION, VENDOR?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.