Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

PScredential class is not storing the credentials provided in script

$
0
0
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

Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>