views:

85

answers:

2

I am working with PowerShell 2.0 with Psake 1.4

Here is the dos command that is running that I want to convert to PowerShell.

"C:\Program Files\Borland\StarTeam 2005 R2\stcmd.exe" co -p "rubble.barney:dinno@HostName:4455/MySolution/WebApp" -is  -fp "D:\FooBar\MySolution\Source"

Notice that the path to stcmd has a space in it
Notice that there is a : between barney:dinno
Notice there area three quoted strings.

Here are my script properties and notes

$AppName = "MySolution"
$StarExe = "C:\Program Files\Borland\StarTeam 2005 R2\stcmd.exe"
$StarProject = "rubble.barney:dinno@HostName:4455/$AppName/WebApp"
$StarOutDir = "D:\FooBar\$AppName\Source"
$StarCommand = """$StarExe"" co -p ""$StarProject"" -is -nologo -q -fp ""$StarOutDir"""

task default -depends GetSource

task Init {
"Working on $AppName"
$ErrorActionPreference = 'Stop'
}

task GetSource -depends Init {
'Get Soure From Star Team'
correct to use invoke? Should it be &, or exec { }
invoke-item $StarCommand }

Any help would be awesome.

+1  A: 

Try this:

& $StarExe co -p $StarProject -is -nologo -q -fp $StarOutDir

Disclaimer: I haven't use psake but I'm not sure why you need so many double quotes around the variables. FWIW the above command should work if executed in a PowerShell script.

Keith Hill
get orf my land! ;-) +1
x0n
You have to watch the PowerShell tag like a hawk to get an answer in edgewise these days. :-)
Keith Hill
I don't even get to answer almost anything here these days :-( – ah well, there's still the `batch` tag :-)
Joey
@Keith + one has to live in the 'right' time zone :)
stej
Heh, yeah that helps too. :-)
Keith Hill
+1  A: 

Try:

& $starexe co -p $StarProject -is -nologo -q -fp $StarOutDir

I presume you're using powershell 2.0. Version 1.0 of powershell had way quirkier native command* argument parsing.

  • native commands = exe, com, bat files etc.

-Oisin

x0n
Razcer
x0n