1

我正在尝试使用 Powershell 中的 COM 对象创建一个清晰的视图。

$ccViews="\\Hostname.global.mycompany.com\cc-view\"
$ViewName="CodeCountView"
$ViewFullpath="$ccViews$ViewName"+".vws"

 $ct = new-object -com ClearCase.ClearTool

     try { 
         $ct.CmdExec('lsview $ViewName') 
     }
     catch {
         $ct.CmdExec('mkview -tag $ViewName -nsh $ViewFullpath')
      }

它引发以下异常。

> Exception calling "CmdExec" with "1" argument(s): "storage directory
> must be in UNC style (e.g. \\host\share\...) " At
> E:\Powershellscripts\CCountAutomation.ps1:81 char:19
> +        $ct.CmdExec <<<< ('mkview -tag $ViewName -nsh $ViewFullpath')
>     + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
>     + FullyQualifiedErrorId : ComMethodTargetInvocation

有人可以帮我解决这个问题吗?

4

2 回答 2

2

尝试更改这些行:

$ct.CmdExec("lsview $ViewName") 

$ct.CmdExec("mkview -tag $ViewName -nsh $ViewFullpath")

使用' $variable '返回字符串 $variable 使用" $variable "返回分配给变量的值。

告诉这个,在你的代码中,你也可以改变这个:

$ViewFullpath="$ccViews$ViewName.vws"
于 2012-02-16T10:08:33.987 回答
2

为了增加(赞成的)克里斯蒂安的答案,我发现的技术说明使用了简单的引号:swg1PK70509

$ct.CmdExec('lsact -fmt `'%[crm_state]p`'

但是在使用变量时,需要使用双引号,如“如何使用 ? 查找[folder]每个组件的根cleartool ”。

于 2012-02-16T10:23:43.113 回答