Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

POWERSHELL - map and umap network folders with diferent credentials

Posted on 2012-08-29
5
Medium Priority
?
699 Views
Last Modified: 2012-08-29
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?
0
Comment
Question by:projectja
  • 2
  • 2
5 Comments
 
LVL 9

Expert Comment

by:TazDevil1674
ID: 38345109
$net = new-object -ComObject WScript.Network
$net.MapNetworkDrive("r:", "\\romeobox\files", $false, "domain\user", "password")
0
 
LVL 14

Expert Comment

by:frankhelk
ID: 38345119
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
 

Author Comment

by:projectja
ID: 38345121
Hi,

Thank you very much.

But how could I disconnect it once I finish the task?
0
 

Author Comment

by:projectja
ID: 38345137
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
 
LVL 9

Accepted Solution

by:
TazDevil1674 earned 2000 total points
ID: 38345235
$net.RemoveNetworkDrive($drive,"true","true")
0

Featured Post

New Tabletop Appliances Blow Competitors Away!

WatchGuard’s new T15, T35 and T55 tabletop UTMs provide the highest-performing security inspection in their class, allowing users at small offices, home offices and distributed enterprises to experience blazing-fast Internet speeds without sacrificing enterprise-grade security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
Loops Section Overview
Screencast - Getting to Know the Pipeline

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question