Hey everyone,
I’m currently working on a script that uploads a file to a remote sharepoint server - the script below is what is currently being used:
$UploadFile = Get-ChildItem $CSV_File # put the file up on SharePoint $webclient = New-Object System.Net.WebClient # set credentials to use $securePassword = ConvertTo-SecureString '' -AsPlainText -force $credentials = new-object System.Management.Automation.PSCredential ("Domain\Account", $securePassword) # upload file $webclient.UploadFile($destination + "/data.csv", "PUT", $Data.csv.FullName)
This method works just fine and uploads the resource to the server. However, I need to authenticate/upload to the remote server without storing the account credentials anywhere on the box. I’ve done this in the past by utilizing the “UseDefaultCredentials” property:
$webclient.UseDefaultCredentials = $true
However, even when switched to True, the credentials aren’t stored and authentication fails. Is there any reason in particular it wouldn’t be storing the credentials properly, and can another method be implemented to avoid storing credentials on the server?
Thanks!