#requires -Version 2 function Get-Software { param ( [string] $DisplayName='*', [string] $UninstallString='*', [string[]] $ComputerName ) [scriptblock]$code = { param ( [string] $DisplayName='*', [string] $UninstallString='*' ) $keys = 'HKLM:SOFTWAREMicrosoftWindowsCurrentVersionUninstall*', 'HKLM:SOFTWAREWow6432NodeMicrosoftWindowsCurrentVersionUninstall*' $result=Get-ItemProperty -Path $keys | Where-Object { $_.DisplayName } | Select-Object -Property DisplayName, DisplayVersion, UninstallString | Where-Object { $_.DisplayName -like $DisplayName } | Where-Object { $_.UninstallString -like $UninstallString } $result #$f=$result -contains '*autodesk*' } if ($PSBoundParameters.ContainsKey('ComputerName')) { Invoke-Command -ScriptBlock $code -ComputerName $ComputerName -ArgumentList $DisplayName, $UninstallString } else { & $code -DisplayName $DisplayName -UninstallString $UninstallString } } #Get-Software -ComputerName "CNKLCNSHSR2001" Import-Csv "C:TempLogspcname.csv" | foreach{ try{ Get-Software -ComputerName $_."pcname" } catch{ } }| export-csv C:TempLogspcname_Result.csv -notypeinformation