Windows Vista Forums

Mapping Network Drive With Username & Password
  1. #1


    Jason Carter Guest

    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

  2. #2


    Shay Levi Guest

    Re: Mapping Network Drive With Username & Password

    Replace True with $true

    Shay
    http://scriptolog.blogspot.com



    > 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

  3. #3


    Karl Mitschke Guest

    Re: Mapping Network Drive With Username & Password

    Hello Jason,

    > 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

  4. #4


    Jason Carter Guest

    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:

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

    > > 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

  5. #5


    Jason Carter Guest

    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:

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

    > > 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

  6. #6


    Shay Levi Guest

    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



    > 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:
    >

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

    >>> 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

Mapping Network Drive With Username & Password problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
backup to a network drive is asking for username and password...whatusername and password? Lisa Hetherington Vista General 7 04 Feb 2008
Logon Username & Password Fails on At Work Network Himanshu Vista networking & sharing 1 19 Oct 2007
Home Network password and username Jonna Vista networking & sharing 1 08 Jun 2007
Mapping drive save password option insidesolutions_64U Vista security 0 29 Apr 2007
Mapping Network Drive username Poisondwarf Vista networking & sharing 0 09 Oct 2006