Windows Vista Forums

Re: Connecting to a share that requires authentication
  1. #1


    Alex K. Angelopoulos Guest

    Re: Connecting to a share that requires authentication

    What do you mean by "only recognizes"? As in, what particular error are you
    getting?

    I suspect that your problem is the omitted profile update value, which
    automatically gets populated (in between strDrivePath and strUser). If you
    tried a direct translation into PS you probably encountered the error
    Missing expression after ','.
    since PowerShell parses the array of values and sees there is nothing
    between the two commas. If you simply omitted the two commas, you would be
    trying to set the flag for updating the profile to the value of the user
    name instead of a true/false value, and PS was probably throwing a type
    mismatch error.

    Here's how you actually want to do this: explicitly include the
    bUpdateProfile boolean that goes between the UNC path and the username; like
    this:



    $net = New-Object -ComObject WScript.Network

    $net.MapNetworkDrive("X:\", "\\server\public", $false, "MyName",
    "MyPassword")

    That should work.


    "Michael Powe" <michael+gnus@xxxxxx> wrote in message
    news:u63plrypv.fsf@xxxxxx

    > Hello,
    >
    > I have a VBS script that connects to a remote share in order to copy
    > files from it. The share requires authentication, which is done in
    > VBS using this code:
    >
    > Set oNetwork = CreateObject("Wscript.Network")
    > oNetwork.MapNetworkDrive strDriveId,
    > strDrivePath,,strUser,strPass
    >
    > From googling, I see how to clone this process in PS, except that the
    > PS connection will not accept the user/password parameters for the
    > call to MapNetworkDrive. It only recognizes a mapping process using
    > the first two parameters.
    >
    > Is there a way, within PS itself, to connect to a remote share that
    > requires authentication? This cannot be interactive, the script is
    > intended to run automatically on a schedule.
    >
    > Thanks.
    >
    > mp
    >
    > --
    > cat: $HOME/.signature: No such file or directory

      My System SpecsSystem Spec

  2. #2


    Michael Powe Guest

    Re: Connecting to a share that requires authentication

    >>>>> "Alex" == Alex K Angelopoulos <aka(at)mvps.org> writes:

    Alex> What do you mean by "only recognizes"? As in, what
    Alex> particular error are you getting?

    Alex> I suspect that your problem is the omitted profile update
    Alex> value, which automatically gets populated (in between
    Alex> strDrivePath and strUser). If you tried a direct translation
    Alex> into PS you probably encountered the error Missing
    Alex> expression after ','. since PowerShell parses the array of
    Alex> values and sees there is nothing between the two commas. If
    Alex> you simply omitted the two commas, you would be trying to
    Alex> set the flag for updating the profile to the value of the
    Alex> user name instead of a true/false value, and PS was probably
    Alex> throwing a type mismatch error.

    Yep, you are right. It was the missing value that was causing the
    problem. Your solution is correct.

    Thank you very much.

    mp

    --
    cat: $HOME/.signature: No such file or directory

      My System SpecsSystem Spec

  3. #3


    Alex K. Angelopoulos Guest

    Re: Connecting to a share that requires authentication

    VBScript is usually pretty straightforward to translate, but the function
    calls can be a problem due to the weird VBScript syntax - and in particular,
    when you see a leading a comma or two commas doubled up in a demo, beware;
    there's some VBScript magic that they're not telling you about. ; )

    "Michael Powe" <michael+gnus@xxxxxx> wrote in message
    news:u3akp3rc5.fsf@xxxxxx

    >>>>>> "Alex" == Alex K Angelopoulos <aka(at)mvps.org> writes:
    >
    > Alex> What do you mean by "only recognizes"? As in, what
    > Alex> particular error are you getting?
    >
    > Alex> I suspect that your problem is the omitted profile update
    > Alex> value, which automatically gets populated (in between
    > Alex> strDrivePath and strUser). If you tried a direct translation
    > Alex> into PS you probably encountered the error Missing
    > Alex> expression after ','. since PowerShell parses the array of
    > Alex> values and sees there is nothing between the two commas. If
    > Alex> you simply omitted the two commas, you would be trying to
    > Alex> set the flag for updating the profile to the value of the
    > Alex> user name instead of a true/false value, and PS was probably
    > Alex> throwing a type mismatch error.
    >
    > Yep, you are right. It was the missing value that was causing the
    > problem. Your solution is correct.
    >
    > Thank you very much.
    >
    > mp
    >
    > --
    > cat: $HOME/.signature: No such file or directory

      My System SpecsSystem Spec

Re: Connecting to a share that requires authentication problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
My server requires authentication t-4-2 Vista mail 2 25 Feb 2009
how to send email if my SMTP server requires authentication BobIT VB Script 3 05 Dec 2008
Re: Connecting to a share that requires authentication Pete Zerger (MVP) PowerShell 0 04 Oct 2008
Mapped drive to 2003 DC always requires authentication after reboo dath Vista account administration 1 16 Mar 2008
My Server requires authentication Jane Vista mail 1 26 Dec 2007