Categories: PowerShellScripts

PowerShell: Find Installed NetApp Products

A slightly modified version of a scriptingGuy post to find NetApp software installed from a csv file (export from active directory)

$ErrorActionPreference= 'silentlycontinue'
$exedir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
#Variables
$LikePublisher = "NetApp"
######
$infile = ($exedir + "\computerlist.csv") 
Write-Host "$infile"
$computers= Import-Csv $infile
$totalComputers = $computers.count
$currentDate = (get-date -uformat "%d%m%Y")
$outfile = ($exedir + "\" + "searchpublisher-" + $LikePublisher + "_" + $currentDate + ".csv")
Write-Host "$outfile"
$checkforoutfile = Test-Path $outfile
If ($checkforoutfile){Remove-Item $outfile}
$counter1 = 0
$array = @()
foreach($pc in $computers){
    $subkeys=$NULL
    $computername=$pc.computername
    $counter1++
    Write-Progress -Activity "Processing" -Status "Processing computer $counter1 of $totalComputers"  -PercentComplete (100 * ($counter1 / $computers.count)) -ID 1
    Write-Progress "Initializing" "Connecting to the Windows System: $computername" -ParentID 1
    #Define the variable to hold the location of Currently Installed Programs
    $UninstallKey="SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall" 
    #Create an instance of the Registry Object and open the HKLM base key
    $reg=[microsoft.win32.registrykey]::OpenRemoteBaseKey('LocalMachine',$computername)
    #Drill down into the Uninstall key using the OpenSubKey Method
    $regkey=$reg.OpenSubKey($UninstallKey) 
    #Retrieve an array of string that contain all the subkey names
    $subkeys=$regkey.GetSubKeyNames()
    #Open each Subkey and use GetValue Method to return the required values for each
    $counter2 = 0
    foreach($key in $subkeys){
        $counter2++
        if ($subkeys.count -eq $NULL){Write-Host "Could not connect to $computername continuing ..."}
        if (($subkeys.count -ne $NULL) -and ($key -NotLike "*KB*")){
		Write-Progress -Activity "Gathering Key information on $computername" -Status "Processing Key $key" -PercentComplete (100 * ($counter2 / $subkeys.count)) -ParentID 1
		$thisKey=$UninstallKey+"\\"+$key 
        	$thisSubKey=$reg.OpenSubKey($thisKey) 
        	$obj = New-Object PSObject
        	$obj | Add-Member -MemberType NoteProperty -Name "ComputerName" -Value $computername
        	$obj | Add-Member -MemberType NoteProperty -Name "DisplayName" -Value $($thisSubKey.GetValue("DisplayName"))
        	$obj | Add-Member -MemberType NoteProperty -Name "DisplayVersion" -Value $($thisSubKey.GetValue("DisplayVersion"))
        	$obj | Add-Member -MemberType NoteProperty -Name "InstallLocation" -Value $($thisSubKey.GetValue("InstallLocation"))
        	$obj | Add-Member -MemberType NoteProperty -Name "Publisher" -Value $($thisSubKey.GetValue("Publisher"))
        	$array += $obj
	}
    } 
}
$array | Where-Object { $_.DisplayName -and $_.Publisher -like "*$LikePublisher*"} | select ComputerName, DisplayName, DisplayVersion, Publisher | ft -auto
$array | Where-Object { $_.DisplayName -and $_.Publisher -like "*$LikePublisher*"} | select ComputerName, DisplayName, DisplayVersion, Publisher | export-csv $outfile
TomLasswell

Share
Published by
TomLasswell

Recent Posts

Autotask: PowerShell: Enable Client Portal for all users

This is a quick one, it's been forever since I've posted here. After moving back…

2 years ago

PowerShell :: Get Exchange Mailboxes Over XXGB

Simple command turned crazy. I ended up coming up with this due to the fact…

4 years ago

PowerShell: ConnectWise Documents API, Uploading a document or attachment to a ticket

Phew, this one took a minute to figure out. ConnectWise has a form based documents…

6 years ago

PowerShell: ConnectWise REST API Query Contacts by Email Address

I've found myself at a new job, recreating many of the processes that I spent…

6 years ago

First post in a long time — changing hosting providers

Wow, it's been a while since I've done a real post on this site. I've…

7 years ago

Powershell: AutoTask – Get Picklist Values

When using AutoTask's API it's required to lookup a various amount of picklist values that…

10 years ago