使用PowerShell执行源安全get by标签的问题

时间:2012-07-13 00:55:46

标签: powershell visual-sourcesafe-2005

我正在尝试使用powershell使用包含空格的标签从srcSafe执行“获取”。

我已经阅读了很多关于如何将params w / space传递给exe的帖子,但我尝试过的任何东西都没有。我的问题似乎是正确提供标签。

以下是cmd行版本(可行)。

ss get $/sandbox/TestSSCmdLine/* -R -I-N -VL"label space"

我最简单的powershell版本是:

ss get '$/sandbox/TestSSCmdLine/*' -R -I-N '-VL\"label space\"'

当我运行powershell cmd时,我没有文件,$ lastexitcode是“100”。

Echo args显示我认为应该是正确的。

Arg 0 is <get>
Arg 1 is <$/sandbox/TestSSCmdLine/*>
Arg 2 is <-R>
Arg 3 is <-I-N>
Arg 4 is <-VL"label space">

Powershell ISE也是如此。

DEBUG: NativeCommandParameterBinder Information: 0 :  WriteLine   Raw argument string:  get $/sandbox/TestSSCmdLine/* -R -I-N "-VL\"label space\""
DEBUG: NativeCommandParameterBinder Information: 0 :  WriteLine   Argument 0: get
DEBUG: NativeCommandParameterBinder Information: 0 :  WriteLine   Argument 1: $/sandbox/TestSSCmdLine/*
DEBUG: NativeCommandParameterBinder Information: 0 :  WriteLine   Argument 2: -R
DEBUG: NativeCommandParameterBinder Information: 0 :  WriteLine   Argument 3: -I-N
DEBUG: NativeCommandParameterBinder Information: 0 :  WriteLine   Argument 4: -VL"label space"

只是为了混淆事情,启动过程似乎有效:

$cmd = "ss.exe"
$args = "get", '$/sandbox/TestSSCmdLine/*', "-R", "-I-N", '-VL"label space"'
$proc = start-process $cmd $args -Wait -NoNewWindow -PassThru -WorkingDir $pwd
$proc.ExitCode

另一个令人困惑的事项是echo args现在将version参数显示为: Arg 4是&lt; -VLlabel space&gt; - &GT;请注意没有空格,也不能使用cmd行。

Thanx任何帮助!

John A.

1 个答案:

答案 0 :(得分:0)

cmd中,引号将用于确保label space作为-VL参数的一部分传递。由于Start-Process版本使用-VLlabel space的结果参数,我会尝试使用ss调用'-VLlabel space',而不使用任何嵌入式引号({{1}}顶部列出的第三个选项3}})。

相关问题