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?