2012-02-16 153 views
1

我想在Powershell中使用COM对象创建一个清晰的视图。CAL mkview命令失败

$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 

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

回答

2

尝试更改这些行:

$ct.CmdExec("lsview $ViewName") 

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

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

告诉本报,在你的代码,你也可以改变这一点:

$ViewFullpath="$ccViews$ViewName.vws"