Let me ask you a question: does your initial Invoke-WebRequest return a 401 status? If not, if you provide a -Credential value on the initial Invoke-WebRequest does it accept the credential or does it respond with a 401 status?
Line 5 and 8: $authenticationDetails is undefined.
Line 12: missing -ErrorAction STOP
Line 15: if the Invoke-WebRequest is successful you still send "Page is down" to the screen.
Line 15: if the Invoke-WebRequest throws an error, the script aborts.
Line 23 and 25: The seem to be a duplicate (with the exception that line 25 doesn't store the result and uses a timeout)
Line 32: You note an error and say there's a status code but you never provide one.
Consider adding "Set-StrictMode -Version Latest" at the beginning of your script. Correct any problems it complains about.