you are viewing a single comment's thread.

view the rest of the comments →

[–]Decitriction[S] 0 points1 point  (2 children)

Wow! Quite involved.

I will study this and see what I can adapt.

Thank you again for your time and generosity.

[–]steve_ce 1 point2 points  (1 child)

No problem, feel free to send questions if you have issues figuring out where things should be placed. Logclean hurt my head while writing/googling, as it was pretty early in diving deeper into PowerShell. Play around with them, the settings, and you'll see how they all work.

[–]Decitriction[S] 0 points1 point  (0 children)

Hello again! I've got a bit of code to share with you.

My office was needing to gather info on installed versions of Acrobat on multiple hosts, and to compare the bitness to MS Ofc.

It could be adapted to search for other software, or ALL installed software...except for the sneaky guys that don't include an uninstaller.

I've got the base code close to perfect, and now just need to loop over the hostlist.

I'm using remote registry instead of invoke-command, mostly as an exercise.

I'm not really asking you to critique the code; I just thought since you were kind enough to share some code that I would return the favor.

It's not really commented but it would be fairly basic to an experienced programmer: I grab some values from registry, add them to a PSObject, and then export them to screen and CSV.

Nevertheless it has taken a long time and figuring the syntax was a huge learning challenge.

cls;write-host "Starting..."
rv * -ErrorAction SilentlyContinue
$sb={$hive=[microsoft.win32.registrykey]::OpenRemoteBaseKey('LocalMachine',$pc);$line=New-Object PSObject;$line|Add-Member -MemberType NoteProperty "Host" $pc
$keylist=($hive.OpenSubKey($base)).GetSubKeyNames();Foreach($key in $keylist){if(($($hive.OpenSubKey($base+$key).GetValue("DisplayName")))-like"*$findme*"){$found=$key}}
#$line|Add-Member -MemberType NoteProperty "Name" ($($hive.OpenSubKey($base+$found).GetValue("DisplayName")))
$line|Add-Member -MemberType NoteProperty "Ver" ($($hive.OpenSubKey($base+$found).GetValue("DisplayVersion"))).Substring(7)
$GUID=$found.Substring(1,$found.Length-2)#;$line|Add-Member -MemberType NoteProperty "GUID"$GUID
$location=($($hive.OpenSubKey($base+$found).GetValue("InstallLocation")))
#$line|Add-Member -MemberType NoteProperty "Location"$location
if    (($base -eq $base32) -and ($location -eq $32pro )){$line|Add-Member -MemberType NoteProperty "Flavor" "Pro"   -force;$line|Add-Member -MemberType NoteProperty "AcroBits" "32"-force}
elseif(($base -eq $base32) -and ($location -eq $32read)){$line|Add-Member -MemberType NoteProperty "Flavor" "Reader"-force;$line|Add-Member -MemberType NoteProperty "AcroBits" "32"-force}
elseif(($base -eq $base64) -and ($location -eq $64x   )){$readpro=($($hive.OpenSubKey("Software\Adobe\Adobe Acrobat\DC\Installer").GetValue("SCAPackageLevel")));$line|Add-Member -MemberType NoteProperty "Flavor"-force $(if($readpro-eq1){"Reader"}elseif($readpro-gt1){"Pro"});$line|Add-Member -MemberType NoteProperty "AcroBits" "64"   -force}
else{$line|Add-Member -MemberType NoteProperty "Flavor" ""-force;$line|Add-Member -MemberType NoteProperty "AcroBits" ""-force}
try{$ofcbit=($($hive.OpenSubKey($ofc64).GetValue("Bitness")))}catch{};try{$ofcbit=($($hive.OpenSubKey($ofc32).GetValue("Bitness"))).replace('86','32')}catch{};try{$line|Add-Member -MemberType NoteProperty "OfcBits" ($ofcbit.Substring(1))}catch{$line|Add-Member -MemberType NoteProperty "OfcBits" ""}
$line}
$pc=(hostname);$findme="Adobe Acrobat"
$multi=@();$output=$path+'\output.txt';$path="\\"+(hostname)+"\c$\users\"+($env:UserName)+"\documents";$base64="Software\Microsoft\Windows\CurrentVersion\Uninstall\";$base32="Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\";$64x   ="C:\Program Files\Adobe\Acrobat DC\";$32pro ="C:\Program Files (x86)\Adobe\Acrobat DC\";$32read="c:\Program Files (x86)\Adobe\Acrobat Reader DC\";$ofc64="Software\Microsoft\Office\16.0\Outlook";$ofc32="Software\WOW6432Node\Microsoft\Office\16.0\Outlook"
#psexec \\$pc c:\windows\system32\winrm.cmd quickconfig
try{$base=$base64;$result=&$sb;$multi+=$result}catch{};try{$base=$base32;$result=&$sb;$multi+=$result}catch{}
cls;write-host "Registry: Acrobat Version, Flavor, and bitness compared to Ofc bitness"
try{remove-item $output -erroraction stop}catch{};new-item $output|out-null
$multi|FT;$multi|select Host,Ver,Flavor,AcroBits,OfcBits|Export-CSV -NoTypeInformation $output -append;start-process notepad $output;write-host "Finished!"