Link to home
Start Free TrialLog in
Avatar of MilesLogan
MilesLoganFlag for United States of America

asked on

Powershell - Pulling multiple attributes for computer objects

Hi guys

I am using the search criteria below to pull some simple information for computer objects.
Is there a way to also pull what patches are installed and if SolidCore is installed and any other HIPS ?

Get-Content Servers.txt | Get-ADComputer -Properties ipv4Address,OperatingSystem, OperatingSystemServicePack,CanonicalName | Select name, ipv4*,IPV6*,oper*,CanonicalName | Export-CSV quickie.csv
Avatar of SubSun
SubSun
Flag of India image

Patch report will be huge and I am not sure if someone go through the entire list.. :-)

Following code I written sometime back to collect the software information from remote computers.. check and see if it works for you..
$PClist = "C:\temp\computers.txt"
$SoftList=@()
GC $PClist | % {
$MachineName = $_
Try {
	$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::'LocalMachine', $MachineName)
	Write-Host "Collecting information from Computer $MachineName" -ForegroundColor Green
	
	#connect to the needed key :

	$regKey= $reg.OpenSubKey("software\Microsoft\Windows\currentversion\uninstall\")

	#and list the properties :

	$programs = $regkey.GetSubKeyNames()
	foreach ($program in $programs)
	{
	    $Soft = ($regKey.OpenSubKey($program)).GetValue("DisplayName")
			If ($Soft -notmatch "Update" -and $Soft -ne $null){
	    $SoftList +=  New-Object PSObject -Property @{
			Computer = $MachineName
			Software = $Soft
				}
			}
		}
	}
	Catch [Exception]{
	Write-Host "Collecting information from Computer $MachineName - Error : $($_.Exception.Message)" -ForegroundColor Red
		$SoftList += New-Object PSObject -Property @{
		Computer = $MachineName
		Software = "Error : $($_.Exception.Message.Trim())"
		}
	}
}
$SoftList | Select Computer,Software | Export-Csv C:\temp\SoftList.csv -NoTypeInformation

Open in new window

Avatar of MilesLogan

ASKER

Hi Subsun .. this is awesome .. can have your script also output the info below ?
OperatingSystem,OperatingSystemServicePack,CanonicalName

Also.. can you give me a quick run down on what exactly it is pulling ? it list all installed applications and all hotfix or  ?
ASKER CERTIFIED SOLUTION
Avatar of SubSun
SubSun
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you so much !