View Single Post
Old 08-02-2007   #3 (permalink)
Jeff


 
 

Re: how to map network drives on a remote computer ?

On Aug 2, 12:20 am, Nicopilami <n.chauss...@gmail.com> wrote:
> Hi everybody, i would like to map a new network drive on a remote
> computer under an admin account, but i didn't find how i could do it.
> Would you have an idea ?
>
> thx
> bye
> Nico


I have something like this in my profile, which allows me to map a
network drive if it hasn't been done yet:

& {
if ( !( Test-Path Z: ) )
{
$net = New-Object -ComObject WScript.Network

$password = Read-Host -AsSecureString "Password for mapped
drive"

$bstr =
[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR( $password )
$password =
[System.Runtime.InteropServices.Marshal]::PtrToStringAuto( $bstr )

[System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR( $bstr )

$net.MapNetworkDrive( "Z:", "\\<server>\<share>", "false",
"<username>", $password )
}
}

Maybe this will get you started. The Read-Host stuff is just so I
don't have to hard-code a password in my $profile.

Good luck.

Jeff

My System SpecsSystem Spec