|
| Calling powershell with spaces in param list |
 |
Tue, 8 Apr 2008 10:46:11 -0700 |
Ok, I have this working on the command line, it just doesn't work when
called from within the script.
Backgroud
I have multiple powershell scripts some powershell scripts call
others. The problem is when script A has to call script B and pass in
a path with a space.I have tried quoting the vars that might contain
spaces in script A and putting the entire param list in a here string
-- neither method works including the here string even though it looks
correct and works when called from a command line. (I output the here
string before using it to validate it).
How do I get these values passed to the second powershell script with
spaces? Help?
Calling code snippet
-------------------------------------
$paramString = @"
& '.\SQLTokenize.ps1' -inputFile "$file" -output
"$OutputPath\$SQBDate\
$fileName" -isInputSQBCheckedout $True
"@
#outputting the here string so I can verify the vars are
correct (with spaces) and quoted
$paramString
powershell "$paramString"
#powershell "& '.\SQLTokenize.ps1' -inputFile "$file"
-output
"$OutputPath\$SQBDate\$fileName" -isInputSQBCheckedout $True"
here string contents
-----------------------------------
& '.\SQLTokenize.ps1' -inputFile "C:\dev\Frameworks\RDA_DB\\Build
\2008\1.30\foo bar.sql" -output "C:\bar\\1.30\\foo bar.sql" -
|
| Post Reply
|
| Re: Calling powershell with spaces in param list |
 |
Tue, 8 Apr 2008 11:51:32 -0700 |
On Apr 8, 12:46 pm, "casey.daniell" <casey.dani...@gmail.com>
wrote:
> Ok, I have this working on the command line, it just doesn't work when
> called from within the script.
>
> Backgroud
> I have multiple powershell scripts some powershell scripts call
> others. The problem is when script A has to call script B and pass in
> a path with a space.I have tried quoting the vars that might contain
> spaces in script A and putting the entire param list in a here string
> -- neither method works including the here string even though it looks
> correct and works when called from a command line. (I output the here
> string before using it to validate it).
>
> How do I get these values passed to the second powershell script with
> spaces? Help?
>
> Calling code snippet
> -------------------------------------
>
> $paramString = @"
> & '.\SQLTokenize.ps1' -inputFile "$file" -output
"$OutputPath\$SQBDate\
> $fileName" -isInputSQBCheckedout $True
> "@
>
> #outputting the here string so I can verify the vars are
> correct (with spaces) and quoted
> $paramString
> powershell "$paramString"
> #powershell "& '.\SQLTokenize.ps1' -inputFile
"$file" -output
> "$OutputPath\$SQBDate\$fileName" -isInputSQBCheckedout
$True"
>
> here string contents
> -----------------------------------
> & '.\SQLTokenize.ps1' -inputFile "C:\dev\Frameworks\RDA_DB\\Build
> \2008\1.30\foo bar.sql" -output "C:\bar\\1.30\\foo bar.sql"
-
> isInputSQBCheckedout True
You don't make it clear what actually DOES happen so I can't
be sure I understand your problem but it looks like this is
the more useful way of setting $paramString.
I am assuming here that you want $file etc to expand
within the source script and not within the new instance of
powershell???
$paramString = "& '.\SQLTokenize.ps1' -inputFile '$file' -output
|
| Post Reply
|
| Re: Calling powershell with spaces in param list |
 |
Tue, 8 Apr 2008 12:08:00 -0700 |
On Apr 8, 1:51 pm, RickB <rbiel...@i1.net> wrote:
> On Apr 8, 12:46 pm, "casey.daniell"
<casey.dani...@gmail.com> wrote:
>
>
>
> > Ok, I have this working on the command line, it just doesn't work
when
> > called from within the script.
>
> > Backgroud
> > I have multiple powershell scripts some powershell scripts call
> > others. The problem is when script A has to call script B and pass in
> > a path with a space.I have tried quoting the vars that might contain
> > spaces in script A and putting the entire param list in a here string
> > -- neither method works including the here string even though it
looks
> > correct and works when called from a command line. (I output the here
> > string before using it to validate it).
>
> > How do I get these values passed to the second powershell script with
> > spaces? Help?
>
> > Calling code snippet
> > -------------------------------------
>
> > $paramString = @"
> > & '.\SQLTokenize.ps1' -inputFile "$file" -output
"$OutputPath\$SQBDate\
> > $fileName" -isInputSQBCheckedout $True
> > "@
>
> > #outputting the here string so I can verify the vars are
> > correct (with spaces) and quoted
> > $paramString
> > powershell "$paramString"
> > #powershell "& '.\SQLTokenize.ps1' -inputFile
"$file" -output
> > "$OutputPath\$SQBDate\$fileName" -isInputSQBCheckedout
$True"
>
> > here string contents
> > -----------------------------------
> > & '.\SQLTokenize.ps1' -inputFile
"C:\dev\Frameworks\RDA_DB\\Build
> > \2008\1.30\foo bar.sql" -output "C:\bar\\1.30\\foo
bar.sql" -
> > isInputSQBCheckedout True
>
> You don't make it clear what actually DOES happen so I can't
> be sure I understand your problem but it looks like this is
> the more useful way of setting $paramString.
> I am assuming here that you want $file etc to expand
> within the source script and not within the new instance of
> powershell???
>
> $paramString = "& '.\SQLTokenize.ps1' -inputFile '$file' -output
> '$OutputPath\$SQBDate\$fileName' -isInputSQBCheckedout $True"
I just found the solution and it was basically what you said to do. I
just had to call the second script with the "&" and drop the
powershell call.
BAD Way
-----------------------------------
powershell "& '.\SQLTokenize.ps1' -inputFile "$file" -output
"$OutputPath\$SQBDate\$fileName" -isInputSQBCheckedout $True"
GOOD Way
---------------------------------
& '.\SQLTokenize.ps1' -inputFile "$file" -output"
$OutputPath\$SQBDate\
|
| Post Reply
|
|
|
|
|
|
|
|
|
|