1

I posted this recently regarding a broken links checker I'm trying to put together but didn't fully understand the problem so fair enough it was closed. I now realise it is as "simple" as pages being hit by the initial invoke-webrequest having embedded content which throws an authentication prompt, but the credentials don't get passed through so it stalls the script until they're entered manually.

$user = 'ad\service-account'
$pwd =  'password'
$securepwd = ConvertTo-SecureString $pwd –asplaintext –force 
$cred = New-Object System.Management.Automation.PSCredential ($user, $securepwd)

$checklinks=(Invoke-WebRequest –Uri $pagePath -Credential $cred -erroraction silentlycontinue ).Links | Where-Object {$_.href -like “http*”} | Select-Object -ExpandProperty href -Unique

Is there any way to either pass the credentials on to the embedded content or suppress the prompt? Cancelling that request is fine rather than entering credentials, but I can't find a way to control this from the code.

The content being prompted for is all within SharePoint and we use Kerberos, so would have thought credentials get passed, but seems not.

1
  • After some testing, this is seemingly a problem with Kerberos on our HNSC web application as it works OK on a non-HNSC web app. Investigating it so can report back if any interest.
    – JamesTown
    Commented May 31, 2017 at 10:16

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.