Problems using powershell to perform a source safe get by label

為{幸葍}努か 提交于 2019-12-11 06:25:35

问题


I'm trying to use powershell to do a "get" from srcSafe using a label that contains spaces.

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.

Following is the cmd line version ( which works ).

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

My simplest powershell version is:

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

When I run the powershell cmd I get no files and $lastexitcode is "100".

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 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

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.

Thanx for any help!

John A.


回答1:


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).



来源:https://stackoverflow.com/questions/11462737/problems-using-powershell-to-perform-a-source-safe-get-by-label

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!