POWERSHELL - map and umap network folders with diferent credentials

Hi,

I am trying to map and unmap x$ to a network server.

That server does not belong the domain so I have to use credential.

I have been looking for information on internet but I am confused, there is methods wth vbs, etc. I am looking for the way to specifically connect by usign powershell and disconnect the share one we finish our work.


Might anyone help me?
projectjaAsked:
Who is Participating?
 
TazDevil1674Connect With a Mentor Commented:
$net.RemoveNetworkDrive($drive,"true","true")
0
 
TazDevil1674Commented:
$net = new-object -ComObject WScript.Network
$net.MapNetworkDrive("r:", "\\romeobox\files", $false, "domain\user", "password")
0
 
frankhelkCommented:
Hmm ... there's already a command for that. Just open a command window and enter try
NET USE /?

Open in new window

for command help. Should be usable in Powershell.
0
 
projectjaAuthor Commented:
Hi,

Thank you very much.

But how could I disconnect it once I finish the task?
0
 
projectjaAuthor Commented:
I prefer not to use NET USE , I would to focus on powershell specifically.

Please, TazDevil1674, how could I discconect the mapped unit ?

Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.