Invoke-WebRequest and find a Value

image_pdfimage_print

Parsing a Website and search for a Value

Mit diesen beiden Skripten durchsuchen wir eine Webseite oder spezifische URL nach einem Wert und lassen uns das Ergebnis anzeigen.

$Server = “www.joernwalter.de”

#$AllProtocols = [System.Net.SecurityProtocolType]’Tls11,Tls12′
#[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols

$S1 = “http://$Server”

$S1Response = (Invoke-WebRequest -Uri $S1 -UseBasicParsing).RawContent -split “`n”
if ($OWAResponse -match “HTTP/1.1 200 OK”)
{
write-host “S1: OK” -foregroundcolor green
}
else
{
write-host “S1: Fehler” -foregroundcolor red
}

$S2Response = (Invoke-WebRequest -Uri $S1 -UseBasicParsing).RawContent -split “`n”
if ($S2Response -like “*Joern Walter*”)
{
write-host “S2: OK” -foregroundcolor green
}
else
{
write-host “S2: Fehler” -foregroundcolor red
}
#(Invoke-WebRequest -Uri $S1 -UseBasicParsing).RawContent -split “`n”

Invoke-WebRequest http

$Server = “www.der-windows-papst.de”

$AllProtocols = [System.Net.SecurityProtocolType]’Tls11,Tls12′
[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols

$S1 = “http://$Server”

$S1Response = (Invoke-WebRequest -Uri $S1 -UseBasicParsing).RawContent -split “`n”
if ($OWAResponse -match “HTTP/1.1 200 OK”)
{
write-host “S1: OK” -foregroundcolor green
}
else
{
write-host “S1: Fehler” -foregroundcolor red
}

$S2Response = (Invoke-WebRequest -Uri $S1 -UseBasicParsing).RawContent -split “`n”
if ($S2Response -like “*IT Blog Essen*”)
{
write-host “S2: OK” -foregroundcolor green
}
else
{
write-host “S2: Fehler” -foregroundcolor red
}
#(Invoke-WebRequest -Uri $S1 -UseBasicParsing).RawContent -split “`n”

Invoke-WebRequest https