![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Script from command-line Ok... I feel as if this worked for me before. From Cmd.exe: powershell "c:\test test\test.ps1" doesn't work. It tells me it doesn't know what "c:\test" is - implying that it's trying to parse the space and ignoring the quotes. Works if the path doesn't contain spaces. It's Friday, it's late, and I'm considering an insanity plea. How do you make this work? -- Don Jones Windows PowerShell MVP Founder: www.ScriptingAnswers.com Co-Author: "Windows PowerShell: TFM" |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Script from command-line "Don Jones [MVP]" <don@xxxxxx> wrote in message news:3DC9E17E-88D0-4565-BD8C-0870E56AD38E@xxxxxx Quote: > Ok... I feel as if this worked for me before. > > From Cmd.exe: > > powershell "c:\test test\test.ps1" > > doesn't work. It tells me it doesn't know what "c:\test" is - implying > that it's trying to parse the space and ignoring the quotes. Works if the > path doesn't contain spaces. It's Friday, it's late, and I'm considering > an insanity plea. > > How do you make this work? Use the -command argument on PowerShell: powershell -command "C:\test test\test.ps1" -- Keith |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Script from command-line Not working in my case PS C:\WINDOWS> powershell -command "C:\test test\test.ps1" The term 'C:\test' is not recognized as a cmdlet, function, operable program, or script file. Verify the term and try again. At line:1 char:8 + C:\test <<<< test\test.ps1 Shay http://scriptolog.blogspot.com Quote: > "Don Jones [MVP]" <don@xxxxxx> wrote in message > news:3DC9E17E-88D0-4565-BD8C-0870E56AD38E@xxxxxx > Quote: >> Ok... I feel as if this worked for me before. >> >> From Cmd.exe: >> >> powershell "c:\test test\test.ps1" >> >> doesn't work. It tells me it doesn't know what "c:\test" is - >> implying that it's trying to parse the space and ignoring the quotes. >> Works if the path doesn't contain spaces. It's Friday, it's late, and >> I'm considering an insanity plea. >> >> How do you make this work? >> > > Use the -command argument on PowerShell: > > powershell -command "C:\test test\test.ps1" > > -- > Keith |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Script from command-line PS C:\WINDOWS> powershell -command "& {test-path 'C:\test test\test.ps1'}" True PS C:\WINDOWS> powershell -command "& {'C:\test test\test.ps1'}" C:\test test\test.ps1 Shay http://scriptolog.blogspot.com Quote: > Not working in my case > > PS C:\WINDOWS> powershell -command "C:\test test\test.ps1" > The term 'C:\test' is not recognized as a cmdlet, function, operable > program, > or script file. Verify the term and try again. > At line:1 char:8 > + C:\test <<<< test\test.ps1 > Shay > http://scriptolog.blogspot.com Quote: >> "Don Jones [MVP]" <don@xxxxxx> wrote in message >> news:3DC9E17E-88D0-4565-BD8C-0870E56AD38E@xxxxxx >> Quote: >>> Ok... I feel as if this worked for me before. >>> >>> From Cmd.exe: >>> >>> powershell "c:\test test\test.ps1" >>> >>> doesn't work. It tells me it doesn't know what "c:\test" is - >>> implying that it's trying to parse the space and ignoring the >>> quotes. Works if the path doesn't contain spaces. It's Friday, it's >>> late, and I'm considering an insanity plea. >>> >>> How do you make this work? >>> >> >> Use the -command argument on PowerShell: >> >> powershell -command "C:\test test\test.ps1" >> >> -- >> Keith |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Script from command-line This one is working, test.ps1 contains just "hello" PS C:\WINDOWS> powershell -command "& {& 'C:\test test\test.ps1'}" hello Shay http://scriptolog.blogspot.com Quote: > PS C:\WINDOWS> powershell -command "& {test-path 'C:\test > test\test.ps1'}" > True > PS C:\WINDOWS> powershell -command "& {'C:\test test\test.ps1'}" > C:\test test\test.ps1 > Shay > http://scriptolog.blogspot.com Quote: >> Not working in my case >> >> PS C:\WINDOWS> powershell -command "C:\test test\test.ps1" >> The term 'C:\test' is not recognized as a cmdlet, function, operable >> program, >> or script file. Verify the term and try again. >> At line:1 char:8 >> + C:\test <<<< test\test.ps1 >> Shay >> http://scriptolog.blogspot.com Quote: >>> "Don Jones [MVP]" <don@xxxxxx> wrote in message >>> news:3DC9E17E-88D0-4565-BD8C-0870E56AD38E@xxxxxx >>> >>>> Ok... I feel as if this worked for me before. >>>> >>>> From Cmd.exe: >>>> >>>> powershell "c:\test test\test.ps1" >>>> >>>> doesn't work. It tells me it doesn't know what "c:\test" is - >>>> implying that it's trying to parse the space and ignoring the >>>> quotes. Works if the path doesn't contain spaces. It's Friday, it's >>>> late, and I'm considering an insanity plea. >>>> >>>> How do you make this work? >>>> >>> Hi Don, >>> >>> Use the -command argument on PowerShell: >>> >>> powershell -command "C:\test test\test.ps1" >>> >>> -- >>> Keith |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Script from command-line "Shay Levi" <no@xxxxxx> wrote in message news:8766a94462c68c9ba5b9e1990f2@xxxxxx Quote: > Not working in my case > > PS C:\WINDOWS> powershell -command "C:\test test\test.ps1" > The term 'C:\test' is not recognized as a cmdlet, function, operable > program, or script file. Verify the term and try again. > At line:1 char:8 > + C:\test <<<< test\test.ps1 > works also: powershell -noprofile -command "& 'c:\temp\foo bar\baz.ps1'" That is pretty close to what you would have to type at the PoSh prompt - just some confusion on the quoting. -- Keith |
My System Specs![]() |
| | #7 (permalink) |
| | Re: Script from command-line On Sep 1, 1:56 am, "Keith Hill [MVP]" <r_keith_h...@xxxxxx_no_spam_I> wrote: Quote: > "Shay Levi" <n...@xxxxxx> wrote in message > > news:8766a94462c68c9ba5b9e1990f2@xxxxxx > Quote: > > Not working in my case Quote: > > PS C:\WINDOWS> powershell -command "C:\test test\test.ps1" > > The term 'C:\test' is not recognized as a cmdlet, function, operable > > program, or script file. Verify the term and try again. > > At line:1 char:8 > > + C:\test <<<< test\test.ps1 > Yeah that little ol' space really throws a monkey wrench in the works. This > works also: > > powershell -noprofile -command "& 'c:\temp\foo bar\baz.ps1'" > > That is pretty close to what you would have to type at the PoSh prompt - > just some confusion on the quoting. > > -- > Keith ----------script---------- # baz.ps1 # write "hello baz, THAT WORKED" ---------------------------- C:\>powershell -command "c:\temp\'foo bar'\baz.ps1" hello baz, THAT WORKED C:\>powershell "c:\temp\'foo bar'\baz.ps1" hello baz, THAT WORKED C:\>powershell 'c:\temp\"foo bar"\baz.ps1' c:\temp"foo bar\baz.ps1 C:\>powershell 'c:\temp\foo bar\baz.ps1' c:\temp\foo bar\baz.ps1 -Hecks |
My System Specs![]() |
| | #8 (permalink) |
| | Re: Script from command-line You can also just single quote or escape the space: powershell "c:\test' 'test\test.ps1" powershell "c:\test` test\test.ps1" -- Kiron |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| How to pass the name of a PowerShell script as a command line para | PowerShell | |||
| noob: PS script fails, but runs from command line | PowerShell | |||
| Running a command from inside a script, command line is corrupted | PowerShell | |||
| Call PS Script with Environment Variable in Path via Command Line | PowerShell | |||
| Running a Command line script from within powershell. | PowerShell | |||