使用Powershell执行源安全标签获取问题 [英] Problems using powershell to perform a source safe get by label
问题描述
我正在尝试使用Powershell使用包含空格的标签从srcSafe执行获取"操作.
I'm trying to use powershell to do a "get" from srcSafe using a label that contains spaces.
我已经阅读了许多关于如何将带空格的参数传递给exe的文章,但我尝试过的所有文章都没有.我的问题似乎是正确提供了标签.
I've read what seems like numerous posts about how to pass params w/spaces to exe's but nothing I've tried works. My problem appears to be supplying the label correctly.
以下是cmd行版本(有效).
Following is the cmd line version ( which works ).
ss get $/sandbox/TestSSCmdLine/* -R -I-N -VL"label space"
我最简单的powershell版本是:
My simplest powershell version is:
ss get '$/sandbox/TestSSCmdLine/*' -R -I-N '-VL\"label space\"'
运行powershell cmd时,我没有任何文件,并且$ lastexitcode为"100".
When I run the powershell cmd I get no files and $lastexitcode is "100".
Echo args显示了我认为应该是正确的.
Echo args shows what I think should be correct.
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显示相同的内容.
Powershell ISE shows the same.
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"
只是混淆启动过程似乎起作用:
Just to confuse things start-process seems to work:
$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是< -VLlabel space>->注意没有空格,也不能从cmd行开始工作.
An additional confusing item is the fact the echo args now shows the version parameter as: Arg 4 is <-VLlabel space> -> note no spaces, also does not work from cmd line.
感谢您的帮助!
John A.
推荐答案
在cmd
中,引号用于确保label space
作为-VL
参数的一部分传递.由于Start-Process
版本的结果参数为-VLlabel space
,因此我将尝试使用'-VLlabel space'
调用ss
,而没有任何嵌入的引号(第三个选项列在
In cmd
, the quotes would have been used to ensure label space
was passed as a part of the -VL
argument. Since the Start-Process
version works with a result argument of -VLlabel space
, I would try calling ss
with '-VLlabel space'
, without any embedded quotes (third option listed at the top of this answer).
这篇关于使用Powershell执行源安全标签获取问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!