Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How do I use -Credential parameter?

133 views
Skip to first unread message

TonyDeSweet

unread,
Feb 4, 2006, 9:50:35 PM2/4/06
to
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
=========================================================

Abhishek Agrawal [MSFT]

unread,
Feb 5, 2006, 1:54:29 AM2/5/06
to
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" <shenzh...@gmail.com> wrote in message
news:1139107835....@o13g2000cwo.googlegroups.com...

0 new messages