Get Installed Agents Windows Server

When I did need to check the Installed Agents in a lot of servers in the network, I decide to try it with an PowerShell Script, this script below do my job easy and quick. This did let me create a file report with each server information that I was looking for.

# Clear Screen
Write-Host Starting Checking proccess..

#Set the PWD to a LocalPath Vab

#Set the name of the file with all Server List to be checked
#Concatenate all the Path and File Name to check
$ListPath=$LocalPath.ToString() + "\" + $FileName.ToString()

#Read  the file  with all servers list and 
$Servers = Get-Content $ListPath

# Loop to check each Server in the list
foreach ($server in $Servers) { 
        Echo "**********************************************************************"
        Echo "Checking host: $Server"  
        Echo "**********************************************************************"
        #Query WMI information from remote system
        $S_error = ""
		Write-Host "Testing connection to $server"
		if (Test-Connection -ComputerName $server -Quiet -count 2){
			 Write-Host "$server is alive and reacheble"
			$Err = Get-WMIObject Win32_BIOS -computername $server -ErrorVariable S_Error -ErrorAction SilentlyContinue
        if ($S_error[0])
	        Write-Host "Having problem connecting to WMI on $Server... "
			Echo "Having problem connecting to WMI on $Server... "
            Echo "**********************************************************************"
            Echo " "

			Write-Host "Getting Information from $Server... "
            $OSInfo = Get-CimInstance win32_OperatingSystem -ComputerName $Server
            $OSInfo | Select-Object -Property @{Name="ComputerName";expression={$_.CSNAME}},@{Name="OS Name";expression={$_.Caption}},@{Name="ServicePack";expression={$_.ServicePackMajorVersion}},@{Name="Architecture";expression={$_.OSArchitecture}},Version,OperatingSystemSKU,@{Name='InstallDate';expression={$_.InstallDate}}
            $Net = Get-WMIObject Win32_NetworkAdapterConfiguration -ComputerName $server -filter ipenabled="true" | Format-List  
            # Echo "CUMPUTER NAME: $Server "
            Echo " NETWORK INFO:" $Net 
            Echo "**********************************************************************"
            $Agents = Get-WmiObject -Query "select * from win32_service where name like'%AmazonSSMAgent%'" -ComputerName $server | Format-Table -Property PSComputerName, Name, ExitCode, Name, ProcessID, StartMode, State, Status
            Echo " AGENTS FOUND at : $Server " $Agents
            Echo "**********************************************************************"
            Echo " " 
            Echo " "
			Echo "**********************************************************************"
            Echo " "

As you can see in the code, you’ll need a file called ServerList.csv in the same folder where you all ready have the past script, please remember that yo must to save the script as “.ps1” file extension.