question

OConnorTim-0598 avatar image
0 Votes"
OConnorTim-0598 asked LimitlessTechnology-2700 edited

Script to get Computer name & office version from remote PC's on domain

Hello All,

I apologize I'm learning PoSH scripts on the fly. I believe the loop is working correctly but I am using Get-WMIObject wrong because I get the error: Get-WMIObject : Invalid query "select machine name here from Win32_Product where Name like '%office%'" InvalidArgument: (:) [Get-WmiObject], ManagementException.

Any help would be much appreciated!


$Adcomp = (get-adcomputer -Filter -SearchBase "directory here*") | Select-Object -ExpandProperty Name
$Results = ForEach ($Computer in $Adcomp) {
$Name = $Computer.Name
$bios = Get-WmiObject Win32_Bios -ComputerName $Computer
$version = Get-WMIObject -Computername $Computer Win32_Product -Filter "Name like '%office%'" $Computer
}
$Results | export-csv C:\test.csv -NoTypeInformation -Append



windows-server-powershell
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you all, I've figured it out thanks to the push in the right direction.

0 Votes 0 ·
LimitlessTechnology-2700 avatar image
0 Votes"
LimitlessTechnology-2700 answered LimitlessTechnology-2700 edited

Hi there,

To find office components installed use this WMI method:

Get-Content -Path c:\scripts\Computers.txt |
ForEach-Object {
Get-WmiObject Win32_Product -Filter "Name like '%Office%'" -ComputerName $_
}

You can find more from this thread
https://social.technet.microsoft.com/Forums/ie/en-US/0487319d-2db7-4369-b95e-83b74fc17313/powershell-script-to-identify-office-version-on-a-remote-system-using-computer-name?forum=ITCG



If the reply is helpful, please Upvote and Accept it as an answer


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AndreasBaumgarten avatar image
0 Votes"
AndreasBaumgarten answered AndreasBaumgarten edited

Hi @OConnorTim-0598 ,

you could try this please:

 $Adcomp = "Computer1","Computer2"
 $Results = ForEach ($Computer in $Adcomp) {
 $Name = $Computer.Name
 $bios = Get-WmiObject Win32_Bios -ComputerName $Computer
 $version = Get-WMIObject -Computername $Computer Win32_Product -Filter "Name like '%office%'"
 $version
 }
 $Results | export-csv C:\Junk\test.csv -NoTypeInformation -Append

Based on your expected result you should modify the output to your needs.


(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

Regards
Andreas Baumgarten

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.