View Single Post
Old 05-02-2007   #2 (permalink)
RichS


 
 

RE: Executing Power Shell Scripts from Windows Shell

Another couple of alternatives to running scripts with spaces in the path

c:\scripts\"test two"\test.ps1

will work. As will

$a = "c:\scripts\test two\test.ps1"
&$a

When the whole path is in quotes powershell will recognise it as a string.
So you either put part of the path in quotes or execute the command within
the string

--
Richard Siddaway
Please note that all scripts are supplied "as is" and with no warranty
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk


"Mugunth" wrote:

> Typing
> powershell "D:\PowerShell Examples\TempScript.ps1"
> on the cmd prompt, gives an error that,
> The term 'D:\PowerShell' is not recognized as a cmdlet, function,
> operable program, or script file. Verify the term and try again.
> I understood that, it was because of the space.
> So I removed the space and tried again and the script executed
> successfully.
>
> However,
> typing
> type "D:\PowerShell Examples\TempScript.ps1"
> on the cmd prompt works fine.
>
> My question is, even when the path is enclosed within double quotes,
> why does powershell not recogonize the entire path and one single
> argument?
>
> Any help would be appreciated.
>
>

My System SpecsSystem Spec