Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Multiple New-PSDrive issue

$
0
0

 

Hello,

 

Please assist me for my below query.

 

I am trying to run the below script in Powershell ISE to copy files between two remote servers

 

Script code:

$pass="<password>"|ConvertTo-SecureString -AsPlainText -Force 

$Cred = New-Object System.Management.Automation.PsCredential("<domain\username>",$pass) 

New-PSDrive -name J -Root "\\<computername1>\e$\test1" -Credential $Cred -PSProvider filesystem 

New-PSDrive -name K -Root "\\<computername2>\e$\test2" -Credential $Cred -PSProvider filesystem 

Copy-Item "\\<computername1>\e$\test1\*" -destination "\\<computername2>\e$\test2\Web" -Recurse -Force 

net use "\\<computername1>\e$" /delete

net use "\\<computername2>\e$" /delete

Remove-PSDrive J

Remove-PSDrive K

 

but getting below error, I tried to google for the same but not getting answer for the same.

"New-PSDrive : Multiple connections to a server or shared resource by the same user, using more than one user name, are not allowed. Disconnect all previous connections 

to the server or shared resource and try again"


Viewing all articles
Browse latest Browse all 6937

Trending Articles