How can I connect to other computers on my home network -specifically through the command prompt or Powershell? The accounts on these computers have passwords. However, I have access to those accounts and passwords.

I need to know in order to create a Powershell script to backup other computers onto a NAS drive or onto an external drive attached to my own PC?

I have tried all of the following from within the command prompt and they have not worked:

  • \\JacksPC\Users\Jack user:Jack Jackspassword
  • \\JacksPC\Users\Jack\ user:Jack Jackspassword
  • \\JacksPC\Users\Jack /user:Jack Jackspassword
  • PSExec \\JacksPC\Users\Jack -u Jack -p Jackspassword -i dir

Essentially, I am seeking to send my credentials across the network, but from within cmd or Powershell. I ultimately wish to manage files and folders. So essentially, I am looking to be able to execute the equivalent of the 'cd', 'dir' and 'copy' commands but over the network and against another computer on my network which is password protected.

I do not wish to map the remote computer to a drive.

  • 1
    "they have not worked" - in what way or error message?
    – harrymc
    Apr 8, 2021 at 13:47
  • I am usually getting a message along the lines of user name or password is not correct when I know it is. I think I may have a subtle. minor error in the syntax I have used but I cannot figure out where I have gone wrong.
    – IqbalHamid
    Apr 8, 2021 at 13:51
  • You mean you haven't tried it before? You might as well delete your question, since there is apparently no problem to solve.
    – harrymc
    Apr 8, 2021 at 14:35
  • I feel there is. That example was very specific. I wish to know what methods there are in general. Not all solutions are universal. For example, specifically on this occasion, I need to know how to pass UNC to the robocopy command's source and destination parameters. If I was to use the DOS copy command, would that also work? I still don't know how I could cd to the sharename or even if that is possible. It also remains unclear why my PSExec commands do not work. I am interested to hear people's thoughts on this scenario. I could not find anything on the internet.
    – IqbalHamid
    Apr 8, 2021 at 20:01
  • Too many questions that are not in your post. You need to be more specific.
    – harrymc
    Apr 8, 2021 at 20:06

1 Answer 1


OK, from my research, I have found that the way to do this is as follows:

NET USE \\remoteserver\IPC$ /USER:userid password
NET USE \\remoteserver\IPC$ /DEL

The top line of code NET USE .... creates a temporary null session connection between the client and server. Your credentials are passed here and the created connection persists (ie: remembered by the system) temporarily. You can then access your restricted, password protected account or resource using its UNC path and you will not be further prompted for credentials. This connection remains until it is deleted by the /DEL switch of the NET USE command in the last line of the script above.

So by way of an example: In my case, I am trying to pass my account credentials to the sourcepath parameter of the robocopy command. I might therefore, enter into my script, the lines of code as follows:

NET USE \\remoteserver\IPC$ /USER:userid password
ROBOCOPY \\remoteserver\sourcepath \\localserver\destpath ...
NET USE \\remoteserver\IPC$ /DEL

A subtle alternative to the above syntax, which does not use IPC$ might be (using specific paths this time):

NET USE \\JacksPC\Users\jack /user:jack jackspassword
dir \\JacksPC\Users\jack\Documents
robocopy \\JacksPC\Users\jack\Documents G:\MyBackups /E /COPY:DAT /DCOPY:DAT /FFT /R:3 /W:10 /ZB
NET USE \\JacksPC\Users\jack /DEL 

NET USE is normally used to map a UNC to a drive letter. However, the drive letter may be omitted as has been done in the examples, above.

I got this information from the only place on the internet that has a copy of the RoboCopy instructions manual. You can find it here...


Not the answer you're looking for? Browse other questions tagged .