0

I'm running a PS script to copy file to a remote server :

$Source = "C:\ListOfNodes.txt"
$Dest   = "\\<IP>\C$\somefile.txt"
$Username = ".\admin"
$Password = "Pass@123"

$WebClient = New-Object System.Net.WebClient
$WebClient.Credentials = New-Object System.Net.NetworkCredential($Username, $Password)

$WebClient.UploadFile($Dest, $Source)

The login credentials are correct, I have tested them using RDP. However, running this script gives me the error below :

Exception calling "UploadFile" with "2" argument(s): "The user name or password is incorrect

Is there another format that needs to be used to provide username and password?

s_om
  • 575
  • 1
  • 8
  • 20
  • Maybe WebClient can be used to access a C$ share on a server, but I'm not finding examples of that. Maybe try something from this answer: https://stackoverflow.com/a/5408972/4190564 – Darin Apr 12 '22 at 20:27

0 Answers0