At first glance, I really want to use New-PSDrive providing my credentials.
> New-PSDrive -Name P -PSProvider FileSystem -Root \\server\share -Credential domain\user
Fails!
New-PSDrive: Cannot retrieve the dynamic parameters for the cmdlet. Dynamic parameters for NewDrive cannot be retrieved for the 'FileSystem' provider. The provider does not support the use of credentials. Please perform the operation again without specifying credentials.
The documentation says that you can provide a PSCredential object PSCredential but if you look closely, the cmdlet does not yet support this. Maybe in the next version, I think.
Therefore, you can use net use or the WScript.Network object by calling the MapNetworkDrive function:
$net = new-object -ComObject WScript.Network $net.MapNetworkDrive("u:", "\\server\share", $false, "domain\user", "password")
Obviously, in new versions of PowerShell, the New-PSDrive works to map network resources to credentials!
New-PSDrive -Name P -PSProvider FileSystem -Root \\Server01\Public -Credential user\domain -Persist
Scott Saad Nov 20 '08 at 15:59 2008-11-20 15:59
source share