Author Posts

January 13, 2017 at 1:44 pm

Dear All,

I am trying to copy the text file “1.txt” to remote share location using start-bitstransfer. I want to copy using a service account that has modify permission on remote share. Below is the code I am working with. However when I run it in Powershell ISE (admin context) I get error -> Start-BitsTransfer : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))access denied. It seems that PScredential class is not storing the credentials provided in script. I say this because when I run the same script to copy “1.txt” to different remote location in Powershell ISE (admin context) it gets copied irrespective of random values I supply in $username & $password variable. Would like to know your thoughts on this. Thanks.

$share = "\\remote\share\"
$username = "domain\username"
$password = “Maz@0*S[f5” | convertto-securestring -AsPlainText -Force
$Credential = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
Start-BitsTransfer -Priority High -Credential $Credential -RetryTimeout 120 -RetryInterval 60 -Source “C:\Programdata\1.txt” -Destination $share

January 14, 2017 at 6:55 pm

As a test, try creating $Credential using New-PSCredential.