2012-02-16 195 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"