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


