PowerShell script, Search multiple devices running a specific version of IE.
I was querying multiple devices running a legacy OS, to check if they are running Internet Explorer v 6, 7 or 8 on the desktop or adjacent desktop spaces. Used this PowerShell.
# Define an array of computer names
$computerNames = @("A_VM_00003", "A81218", "95715", "A95917", "A96288", "A98785", "CWS027", "NET270CLA", "CITAPP08", "QSTR01")
# Function to check IE version on a single computer
function Check-IEVersion($computerName) {
Write-Output "Checking $computerName..."
# Get all running Internet Explorer processes
$ieProcesses = Get-WmiObject -Class Win32_Process -ComputerName $computerName -ErrorAction SilentlyContinue |
Where-Object { $_.Name -eq "iexplore.exe" }
if ($ieProcesses) {
foreach ($process in $ieProcesses) {
# Get the IE version from the registry
$ieVersion = Invoke-Command -ComputerName $computerName -ScriptBlock {
$regKey = "HKLM:\SOFTWARE\Microsoft\Internet Explorer"
(Get-ItemProperty -Path $regKey -Name "Version" -ErrorAction SilentlyContinue).Version
} -ErrorAction SilentlyContinue
# Check if the version is 6, 7, or 8
if ($ieVersion -match "^[6-8]\.") {
$processInfo = Get-WmiObject -Class Win32_Process -ComputerName $computerName |
Where-Object { $_.ProcessId -eq $process.ProcessId }
$windowTitle = $processInfo.GetOwner().User
Write-Output " Internet Explorer $ieVersion is running on $computerName"
Write-Output " Process ID: $($process.ProcessId)"
Write-Output " Window Title: $windowTitle"
Write-Output " -----------------------------"
}
}
} else {
Write-Output " No Internet Explorer processes found running on $computerName"
}
Write-Output ""
}
# Main script execution
foreach ($computer in $computerNames) {
Check-IEVersion $computer
}