How do I use -Credential parameter?
- From: "TonyDeSweet" <shenzhonghao@xxxxxxxxx>
- Date: 4 Feb 2006 18:50:35 -0800
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
=========================================================
.
- Follow-Ups:
- Re: How do I use -Credential parameter?
- From: Abhishek Agrawal [MSFT]
- Re: How do I use -Credential parameter?
- Prev by Date: Re: [MSH] MSH Not So Great For Interactive Users
- Next by Date: Re: How do I use -Credential parameter?
- Previous by thread: Creating "Home" dirs via script
- Next by thread: Re: How do I use -Credential parameter?
- Index(es):
Relevant Pages
|