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

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

1 Answers1

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
Vivek Kumar Singh
  • 3,223
  • 1
  • 14
  • 27
  • Hello, thanks for your help but the column is still coming up blank when I export to .csv – Dan Goodwin May 16 '18 at 10:41
  • 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`? – Vivek Kumar Singh May 16 '18 at 11:31