1

I am trying to create a clearcase view using COM object in Powershell.

$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')
      }

It throws following exception.

> 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

Can some one help me to solve this?

Samselvaprabu
  • 16,830
  • 32
  • 144
  • 230

2 Answers2

2

Try change these lines:

$ct.CmdExec("lsview $ViewName") 

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

Using ' $variable ' return the string $variable Using " $variable " return the value asign to the variable.

Told this, in your code, you can also change this:

$ViewFullpath="$ccViews$ViewName.vws"
CB.
  • 58,865
  • 9
  • 159
  • 159
2

To add to the (upvoted) Christian's answer, the technotes I found uses simple quotes: swg1PK70509

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

But when using variable, double quotes are required, as illustrated in "how to find root [folder] for each component using cleartool?".

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250