Script Center
Sign in
United States (English)
Australia (English)
Brasil (Português)
Česká republika (Čeština)
Danmark (Dansk)
Deutschland (Deutsch)
España (Español)
France (Français)
Indonesia (Bahasa Indonesia)
Italia (Italiano)
Magyarország (Magyar)
Polska (Polski)
Россия (Русский)
대한민국 (한국어)
中华人民共和国 (中文)
台灣 (中文)
日本 (日本語)
香港特别行政區 (中文)
Resources for IT Professionals
Home
Library
Learn
Downloads
Scripts
Forums
Script Center
>
Scripting Forums
>
The Official Scripting Guys Forum!
>
Newbie : Syntax Problem in Powershell
Ask a question
Search Forums:
Search The Official Scripting Guys Forum! Forum
Search All Scripting Forums
Search All Microsoft TechNet Forums
Newbie : Syntax Problem in Powershell
Friday, November 20, 2009 8:58 PM
saurabh180407
0
Sign In to Vote
# setting the folder location
$loc = 'e:\dsain\dc prd'
# i want to use dos command from power shell to list the contents of above dir
# i am using following command
invoke-expression "cd $loc : dir"
i get an error
Set-Location : A parameter cannot be found that matches parameter name 'prd'.
At line:1 char:3
+ cd <<<< e:\saurabh\eain preid dir
--it works fine if there is no space in folder name i.e
if
$loc = 'e:\dsain\dcprd'
student
Reply
Quote
Answers
Friday, November 20, 2009 9:30 PM
mjolinor
0
Sign In to Vote
Try this:
$loc = '"e:\dsain\dc prd"'
invoke-expression "cmd /c dir $loc"
Marked As Answer by
IamMred
MSFT
, Owner
Friday, January 15, 2010 8:37 AM
Reply
Quote
All Replies
Friday, November 20, 2009 9:30 PM
mjolinor
0
Sign In to Vote
Try this:
$loc = '"e:\dsain\dc prd"'
invoke-expression "cmd /c dir $loc"
Marked As Answer by
IamMred
MSFT
, Owner
Friday, January 15, 2010 8:37 AM
Reply
Quote
Friday, November 20, 2009 10:04 PM
saurabh180407
0
Sign In to Vote
that works......thanks a lot..
student
Reply
Quote
Saturday, November 21, 2009 9:24 PM
Shay Levi
MVP
, Moderator
0
Sign In to Vote
From within PowerShell You can simply do:
dir e:\dsain\dc prd
or
cmd /c dir e:\dsain\dc prd
Anyway, why resorting to DOS?
Shay Levy [MVP]
http://blogs.microsoft.co.il/blogs/ScriptFanatic
PowerShell Toolbar
Reply
Quote
Sunday, November 22, 2009 4:29 AM
AbqBill
Moderator
0
Sign In to Vote
DOS? Surely you mean Cmd.exe? :-)
Bill
Reply
Quote
Sunday, November 22, 2009 7:34 AM
Shay Levi
MVP
, Moderator
0
Sign In to Vote
CMD, Right...duh ;-)
Shay Levy [MVP]
http://blogs.microsoft.co.il/blogs/ScriptFanatic
PowerShell Toolbar
Reply
Quote
Need Help with Forums? (FAQ)
© 2010 Microsoft Corporation. All rights reserved.
Terms of Use
|
Trademarks
|
Privacy Statement
|
Contact Us