I need to download a PDF file from a SharePoint Server that requires SmartCard Authentication. This powershell file will need to be run multiple times a day and by different users. The only method of authentication is via SmartCard. How can I do this?
I have tried the following method, where I first tried to retrieve credentials from:
$object = new-object Microsoft.VisualBasic.Devices.Network
Write-Host “Please Select SmartCard from dropdown and enter PIN.”;
$credential = $host.ui.PromptForCredential(“Need credentials”, “Please enter your user name and password.”, “”, “NetBiosUserName”)
then did the following:
$web.Credentials = $credential
$object.DownloadFile($url, $path, $credential.username, $credential.password , $true, 500, $true, ‘DoNothing’)
Neither method worked.
If I create an instance of internet explorer I can open the PDF file, but I cannot get it to download automatically. Ideally, besides opening the powershell file and clicking authenticate on the SmartCard popup, everything should be invisible to the user. If not invisible, then everything would close down.