I've been looking for a solid example of a working PowerShell component monitor. I've been struggling with 'Not Defined' and I've been looking for a solid current example.
I've located quite a few examples but without success.
I'm trying to compare to arrays of IP Addresses.
My Current (not working):
# Query external DNS server and store output as string
# Querying dns.google
$ExtIPs = Resolve-DnsName MyCompany.ca -DnsOnly -server 8.8.8.8 | Select-Object -ExpandProperty IPAddress | Sort-Object -Descending
# Setting the IntIP to match External IPs
$IntIPs = ('7.77.77.207','7.23.98.149')
# Check to see if IPs if are the same
$ListsEqual = $true
IF (diff $IntIPs $ExtIPs)
{
$ListsEqual = $false
Write-Host "Statistic: 1"
Write-Host "Message:" $ListsEqual
exit 1
}
ELSE
{
$ListsEqual = $true
Write-Host "Statistic: 0"
Write-Host "Message:" $ListsEqual
exit 0