RedPlug's Tory

#아이피 체크 함수
function AlertIP($server="dns.test.com", $queryaddress="www.google.co.kr", $wrongIP="168.126.63.1"){   
    $result = resolve-dnsname $queryaddress -Type A -Server $server
    if($result.IP4Address -eq $wrongIP){
        $body = ConvertTo-Json @{
            # pretext = "DNS Alert www.google.co.kr"
            text = $queraddress "A Record is return " $wrongIP
            color = "#142954"
        }
 		# 슬랙 웹훅
        try {
            Invoke-RestMethod -uri $uriSlack -Method Post -body $body -ContentType 'application/json' | Out-Null
        } catch {
            Write-Error (Get-Date) ": Update to Slack went wrong..."
        }
        # 팝업 발생
        $msg = New-Object -ComObject WScript.Shell
 
        $msg.POpup("알람", 5, "알람", 48)
    }
    write-host $Server "IP :" $result.IP4Address   
}
 
#슬랙 웹훅 주소 수정 해서 사용
$uriSlack = "https://hooks.slack.com/services/{GUID}"
 
# 실제
for(;;) {
    get-date
    AlertIP "dns1.test.com" "www.google.co.kr" "168.126.63.1"
    AlertIP "dns2.test.com"
    sleep 10
    write-host "===================================="
}