Using PowerShell, I was looking for a way to query / search a webpage for a string / variable. If the string was found, do something.
When trying to access a SharePoint page, I needed to use the UseDefaultCredentials = $true function, otherwise I was seeing random errors.
Error example:
The remote server returned an error: (401) Unauthorized.
$web = New-Object System.Net.WebClient
$web.UseDefaultCredentials = $true
If ($web.DownloadString(“http://www.yoursite.com/taco.aspx”)| select-string “Taco”)
{
Write-Host “True”
}
Else
{
Write-Host “False”
}