Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Mapping Network Drive With Username & Password

Reply
 
Old 08-30-2007   #1 (permalink)
Jason Carter


 
 

Mapping Network Drive With Username & Password

Does this look correct for mapping a network drive and passing the correct
username and password along with it for authentication?

$net = New-Object -ComObject WScript.Network
$net.MapNetworkDrive( "X:", "\\servername\share", "true", "<username>",
"PASSWORD")

My System SpecsSystem Spec
Old 08-30-2007   #2 (permalink)
Shay Levi


 
 

Re: Mapping Network Drive With Username & Password

Replace True with $true

Shay
http://scriptolog.blogspot.com


Quote:

> Does this look correct for mapping a network drive and passing the
> correct username and password along with it for authentication?
>
> $net = New-Object -ComObject WScript.Network
> $net.MapNetworkDrive( "X:", "\\servername\share", "true",
> "<username>",
> "PASSWORD")

My System SpecsSystem Spec
Old 08-30-2007   #3 (permalink)
Karl Mitschke


 
 

Re: Mapping Network Drive With Username & Password

Hello Jason,
Quote:

> Does this look correct for mapping a network drive and passing the
> correct username and password along with it for authentication?
>
> $net = New-Object -ComObject WScript.Network
> $net.MapNetworkDrive( "X:", "\\servername\share", "true",
> "<username>",
> "PASSWORD")
I use:

$cred = get-credential "user"
$domain = "."
$user = $cred.UserName
$net = New-Object -com WScript.Network
$pwd = $cred.Password
$drive = "F:"
$path = "\\server\share";
$net.RemoveNetworkDrive($drive)
$net.mapnetworkdrive($drive, $path, "true", $user, $cred.GetNetworkCredential().Password)

Karl


My System SpecsSystem Spec
Old 08-31-2007   #4 (permalink)
Jason Carter


 
 

Re: Mapping Network Drive With Username & Password

OK, it works if I use my username and password and I am currently logged in.
When I try to access a share I dont' have access to, it gives me an error
even if I put in the username and password for the person who has access.

I want this to run in a script each night without somebody being logged into
the machine to copy log files over to a network share on another machine.
Any more ideas?

I know have:


$net = New-Object -ComObject WScript.Network
$net.MapNetworkDrive( "N:", "\\servername\share", "$true", "USERNAME",
"PASSWORD")



"Shay Levi" wrote:
Quote:

> Replace True with $true
>
> Shay
> http://scriptolog.blogspot.com
>
>
>
Quote:

> > Does this look correct for mapping a network drive and passing the
> > correct username and password along with it for authentication?
> >
> > $net = New-Object -ComObject WScript.Network
> > $net.MapNetworkDrive( "X:", "\\servername\share", "true",
> > "<username>",
> > "PASSWORD")
>
>
>
My System SpecsSystem Spec
Old 08-31-2007   #5 (permalink)
Jason Carter


 
 

Re: Mapping Network Drive With Username & Password

I might also add that this is going to a Linux password network storage
device that has its own username and password that I need to supply to
connect to it. I can connect to it fine going through the RUN command and
giving it the path, the login box pops up, I put in the username and password
and I connect. It doesn't use domain authentication like
domainname\username, just a straight username and password

Just thought I would give some more info if anybody has any ideas.

"Shay Levi" wrote:
Quote:

> Replace True with $true
>
> Shay
> http://scriptolog.blogspot.com
>
>
>
Quote:

> > Does this look correct for mapping a network drive and passing the
> > correct username and password along with it for authentication?
> >
> > $net = New-Object -ComObject WScript.Network
> > $net.MapNetworkDrive( "X:", "\\servername\share", "true",
> > "<username>",
> > "PASSWORD")
>
>
>
My System SpecsSystem Spec
Old 08-31-2007   #6 (permalink)
Shay Levi


 
 

Re: Mapping Network Drive With Username & Password

I cant test it right now but try to remove the double quotes, use only $true
(though it's used only for permanant mapping)

Shay
http://scriptolog.blogspot.com


Quote:

> OK, it works if I use my username and password and I am currently
> logged in. When I try to access a share I dont' have access to, it
> gives me an error even if I put in the username and password for the
> person who has access.
>
> I want this to run in a script each night without somebody being
> logged into the machine to copy log files over to a network share on
> another machine. Any more ideas?
>
> I know have:
>
> $net = New-Object -ComObject WScript.Network
> $net.MapNetworkDrive( "N:", "\\servername\share", "$true", "USERNAME",
> "PASSWORD")
> "Shay Levi" wrote:
>
Quote:

>> Replace True with $true
>>
>> Shay
>> http://scriptolog.blogspot.com
Quote:

>>> Does this look correct for mapping a network drive and passing the
>>> correct username and password along with it for authentication?
>>>
>>> $net = New-Object -ComObject WScript.Network
>>> $net.MapNetworkDrive( "X:", "\\servername\share", "true",
>>> "<username>",
>>> "PASSWORD")

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
backup to a network drive is asking for username and password...whatusername and password? Vista General
Logon Username & Password Fails on At Work Network Vista networking & sharing
Home Network password and username Vista networking & sharing
Mapping drive save password option Vista security
Mapping Network Drive username Vista networking & sharing


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46