-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChkForApplication.ps1
31 lines (24 loc) · 1.07 KB
/
ChkForApplication.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Script enumerates AD servers, then enumerates a list of installed programs via wmi and looks of a specific application
$servers = Get-ADServers
$serverNames = $servers.properties.name
"" | Out-File -FilePath "C:\success_output.txt"
"" | Out-File -FilePath "C:\unsuccessful_orError.txt"
"" | Out-File -FilePath "C:\noRepsonse.txt"
foreach ($i in $serverNames)
{
if ((Test-Connection -ComputerName $i -Quiet -Count 1) -eq $true)
{
$tryWMI = Get-WmiObject -computername $i -Class Win32Reg_AddRemovePrograms -ErrorAction SilentlyContinue | Select-Object DisplayName | Where-Object {$_.DisplayName -like "[application]"}
if ($tryWMI -ne $null)
{
$i | Out-File -Append -FilePath "C:\success_output.txt"
echo "$i has networker"
} else {
$i | Out-File -Append -FilePath "C:\unsuccessful_orError.txt"
echo "$i does not have networker or has an error"
}
} else {
$i | Out-File -Append -FilePath "C:\noRepsonse.txt"
echo "$i does not respond to ping"
}
}