New-PSDrive does not support credentials?
Asked Answered
S

3

7

I am trying to map a drive in PowerShell 2.0 and getting this error?

New-PSDrive –Name ftp –PSProvider FileSystem –Root “\\server\folder” -Credential $credential
The provider does not support the use of credentials. Perform the operation again without specifying credentials.

However, Get-Help New-PSDrive shows -Credential as a valid option?

Is this a version issue in PS? Is there an alternative way to do the same...I would prefer to keep this within PS (since the drive is PS only then) and not drop out to NET USE - NET USE /d but needs must!

Seessel answered 11/6, 2013 at 5:15 Comment(1)
FYI This has been fixed in 3.0.Diadelphous
P
9

It's a bug in PowerShell 2.0

Workaround from the above link:

$net = new-object -ComObject WScript.Network
$net.MapNetworkDrive("u:", "\\server\share", $false, "domain\user", "password")

Supposedly fixed in 3.0 (I haven't tested it myself).

Pompey answered 11/6, 2013 at 14:4 Comment(5)
Curious attitude from Microsoft. First they make a release that has this bug in the first place - quite embarrassing that the core thing you'd want to do doesn't actually work. Then they decide to wait 3 freaking years to fix it (from Server 2008 R2, released in 2009, to Server 2012.) Should have caught it in QA long before release. And then when it was caught, should have been an immediate hotfix for it and the broken version should have been immediately retracted. Who needs silly things like security though.Refluent
How is this a workaround? how to use it instead of the -Credential ? Microsoft Connect is retired, and the link is deadTreen
@Treen you're responding to an answer that's six years old, and the versions noted are obsolete at this point.Pompey
It's unfortunate but sometimes you have to keep using the old versions for your clients. So yes, i'm still using PowerShell V2Treen
@Treen Powershell 2 is now considered a security risk. It behooves your clients to upgrade to a newer release. petri.com/…Pompey
D
2

If you still get the error after installing KB2819745 (powershell 4) then you might have forgotten Dotnet 4.5.

DotNet 4.5 is a requirement for WinRM 4 / Powershell 4, yet the msu installs without it.

This was the issue i was facing, after installing KB2819745 i still got the error. Install Dotnet 4.5 and then rerun KB2819745. Strangely it will reinstall when you installed dotnet, but without dotnet it says its already installed

Dearr answered 29/1, 2015 at 7:20 Comment(1)
ty for the tip! Note that Finding the WMF version may not be a simple " if ( ( Get-HotFix KB2819745 ) -ne $null ) {"ok"} else {"not found"}" or test of "$$PSVersionTable.PSVersion" due to posh being a subset of WMF. See this issue; 1.[] ; ; ; ; ; X.CredSSP should allow delegation of “Default” (current) credentials | Microsoft Connect ; ; connect.microsoft.com/PowerShell/Feedback/Details/498377Claustrophobia
S
1

echo "pass"| net use \\server\share /user:domain\user

it is also working :)

Shimmer answered 11/12, 2013 at 9:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.