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.

Razcer
  • 394
  • 4
  • 17

2 Answers2

4

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
  • 51,312
  • 7
  • 89
  • 111
  • That I tried & $StarExe co -p $StarProject -is -nologo -q -fp $StarOutDir and got: Cannot find drive. A drive with the name '"C' does not exist. – Razcer Jun 22 '10 at 21:59
  • bizarre. have you tested it with really simple arguments, like "& $prog" where $prog is, um, say "c:\windows\system32\cmd.exe" ? – x0n Jun 23 '10 at 20:25
  • It was a quotes issue with the path in the variable, doh! – Razcer Jan 20 '11 at 15:39
3

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
  • 194,368
  • 42
  • 353
  • 369