![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Why does this command not work? Hello Does anyone know what I am doing wrong here? Provider | foreach-object {$_.drives} | foreach-object {$a = $_.name + ":\"; & "dir $a"} I get the following message per provider. 'dir Alias:\' is not recognized as a cmdlet, function, operable program, or script file. At line:1 char:85 + get-psprovider | foreach-object {$_.drives} | foreach-object {$a = $_.name + ":\"; &" <<<< dir $a"} 'dir Env:\' is not recognized as a cmdlet, function, operable program, or script file. At line:1 char:85 + get-psprovider | foreach-object {$_.drives} | foreach-object {$a = $_.name + ":\"; &" <<<< dir $a"} Seems to me that "dir Env:\" does work if I type it in and execute it, but not if I make the command from the providers collection. Any help appreciated. Thanks |
My System Specs![]() |
| | #2 (permalink) |
| Guest | RE: Why does this command not work? This seemed to work for me Get-PSProvider | ForEach-Object{$_.drives} | ForEach-Object{$a = $_.name + ":\"; dir $a} I don't think you needed the & and " " around dir $a -- Richard Siddaway Please note that all scripts are supplied "as is" and with no warranty "MadBison@gmail.com" wrote: > Hello > > Does anyone know what I am doing wrong here? > Provider | foreach-object {$_.drives} | foreach-object {$a = $_.name + > ":\"; & "dir $a"} > > I get the following message per provider. > > 'dir Alias:\' is not recognized as a cmdlet, function, operable > program, or script file. > At line:1 char:85 > + get-psprovider | foreach-object {$_.drives} | foreach-object {$a = > $_.name + ":\"; &" <<<< dir $a"} > 'dir Env:\' is not recognized as a cmdlet, function, operable program, > or script file. > At line:1 char:85 > + get-psprovider | foreach-object {$_.drives} | foreach-object {$a = > $_.name + ":\"; &" <<<< dir $a"} > > Seems to me that "dir Env:\" does work if I type it in and execute it, > but not if I make the command from the providers collection. > > Any help appreciated. > Thanks > > |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: Why does this command not work? "RichS" <RichS@discussions.microsoft.com> wrote in message news:047CFB06-03F9-413E-B82B-87E40F88F59E@microsoft.com... > This seemed to work for me > > Get-PSProvider | ForEach-Object{$_.drives} | ForEach-Object{$a = $_.name + > ":\"; dir $a} > > I don't think you needed the & and " " around dir $a In addition, see the recent thread called "Execute a command in a string" for an explanation why & "dir $a" doesn't work. Jacques |
My System Specs![]() |
| | #4 (permalink) |
| Guest | Re: Why does this command not work? MadBison@gmail.com wrote: > Hello > > Does anyone know what I am doing wrong here? > Provider | foreach-object {$_.drives} | foreach-object {$a = $_.name + > ":\"; & "dir $a"} If you insist to use wrap "dir $a" with quotes, then you can invoke-expression the string as follows: get-psprovider | foreach-object {$_.drives} | foreach-object {$a = $_.name + ":\"; invoke-expression "dir $a"} But as Jacques Barathon mentioned, there is no need for "&" or "invoke-expression" just call "dir $a" without double quotes around it. get-psprovider | foreach-object {$_.drives} | foreach-object {$a = $_.name + ":\"; dir $a} |
My System Specs![]() |
| | #5 (permalink) |
| Guest | Re: Why does this command not work? Thanks everyone for your help. Indeed, removing the & and quotes did the trick. Get-PSProvider | foreach-object {$_.drives}| foreach-object {$a = $_.name + ":\"; dir $a} Thanks Sung M Kim wrote: > MadBison@gmail.com wrote: > > Hello > > > > Does anyone know what I am doing wrong here? > > Provider | foreach-object {$_.drives} | foreach-object {$a = $_.name + > > ":\"; & "dir $a"} > > If you insist to use wrap "dir $a" with quotes, then you can > invoke-expression the string as follows: > > get-psprovider | foreach-object {$_.drives} | foreach-object {$a = > $_.name + ":\"; invoke-expression "dir $a"} > > But as Jacques Barathon mentioned, there is no need for "&" or > "invoke-expression" just call "dir $a" without double quotes around > it. > > get-psprovider | foreach-object {$_.drives} | foreach-object {$a = > $_.name + ":\"; dir $a} |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Re: My command promt deosnt work | GTS | Vista General | 1 | 04-26-2008 02:08 AM |
| MSMAPI32 FETCH COMMAND DON'T NOT WORK IN WINDOWS MAIL ! | Alex | Vista mail | 0 | 03-01-2007 11:46 AM |
| Route command doesn't work | Luca | Vista networking & sharing | 0 | 06-14-2006 07:31 AM |
| Route command doesn't work | Luca | Vista networking & sharing | 0 | 06-14-2006 06:32 AM |
| Route command doesn't work | Luca | Vista networking & sharing | 0 | 06-14-2006 06:31 AM |