Re: How do I use -Credential parameter?



FileSystem and Registry provider do not supprt Credential parameter for V1.
We plan to address this in V2. For now you will need to start an elevated
MSH window using runas.exe (or Process.Start api) and carry out the required
operations there.

Abhishek Agrawal [MSFT]
MSH Team
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.


"TonyDeSweet" <shenzhonghao@xxxxxxxxx> wrote in message
news:1139107835.052458.13080@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
There are some buildin cmdlets with -Credential parameter (for example
those *-Item cmdlet). But when I used those cmdlet with -Credential, I
always got an error (no matter it is Filesystem provider or registry
provider).

Is there something I did wrong or Is it designed to act like that?

=======================================================
C:\WINDOWS> new-item . -Name my.txt -type "file"
new-item : Access to the path 'C:\WINDOWS\my.txt' is denied.
At line:1 char:9
+ new-item <<<< . -Name my.txt -type "file"
=======================================================
C:\WINDOWS> new-item . -Name my.txt -type "file" -Credential Admin

Credential Information
Please enter your credentials.
Password for user Admin: ******

new-item : Dynamic parameters for the Cmdlet cannot be retrieved.
Invocation of
MakePath on the 'FileSystem' provider failed for path 'C:\'. Cannot
call metho
d. The provider does not support the use of credentials.
At line:1 char:9
+ new-item <<<< . -Name my.txt -type "file" -Credential Admin
=======================================================
C:\WINDOWS> $me=get-credential

Cmdlet get-credential at command pipeline position 1
Supply values for the following parameters:
Credential
User: Admin
Password for user Admin: ******

C:\WINDOWS> new-item . -Name my.txt -type "file" -Credential $me
new-item : Dynamic parameters for the Cmdlet cannot be retrieved.
Invocation of
MakePath on the 'FileSystem' provider failed for path 'C:\'. Cannot
call metho
d. The provider does not support the use of credentials.
At line:1 char:9
+ new-item <<<< . -Name my.txt -type "file" -Credential $me
=========================================================



.



Relevant Pages

  • How do I use -Credential parameter?
    ... But when I used those cmdlet with -Credential, ... always got an error (no matter it is Filesystem provider or registry ... MakePath on the 'FileSystem' provider failed for path 'C:\'. ... The provider does not support the use of credentials. ...
    (microsoft.public.windows.server.scripting)
  • RE: Once again Vista logon (ICredentialProvider)
    ... I don't manage to retrieve the credentials. ... I can register the DLL with XP but I can't do that with Vista. ... >> You don't have to care much about the Credential Providers subkey, ... >> some friendly name as its default value (My Provider). ...
    (microsoft.public.platformsdk.security)
  • Re: Impersonation problem
    ... The statement about any provider being able to take credentials is not ... Joe Kaplan-MS MVP Directory Services Programming ... Co-author of "The .NET Developer's Guide to Directory Services Programming" ...
    (microsoft.public.dotnet.security)
  • Re: Macbook Pro und Linux
    ... laufender Daemon hinter meinem Rücken mit meinen Credentials beim ... IMAP-Server anmelden würde. ... Wo hast Du "Provider" gelesen? ...
    (de.comp.sys.mac.misc)
  • Re: [MSH]about cmdlets hidden parameters question
    ... The provider cmdlets like get-childitem using the ... parameters for the cmdlet. ... {Path, Filter, Include, Exclude, Recurse, Force, Verbose, ... (get-command get-content).parametersets" ...
    (microsoft.public.windows.server.scripting)