Search code examples
powershelldosstarteampsake

Converting Dos Command to Power Shell command


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.


Solution

  • 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