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.