Question

Can we use Commvault PowershellSDK Module inside Workflow

  • 20 October 2023
  • 5 replies
  • 50 views

Badge +6

I have created a powershell script using powershell sdk module to run multiple vm level backups which runs the backup but when i use the same powershelll script inside a workflow it doesnt work for some reason giving me message : I NFO: Get-CVClient: client not found having id [0]. 

 

Is there some limitation or something wrong the way i am passing the scrip inside workflow.


5 replies

Userlevel 3
Badge +6

Can you post the script you are using?

Badge +6

$string = {xpath:{/workflow/inputs/VM/clientName}}
$string = $string -replace('\[','')
$string = $string -replace('\]','')
$string = $string -replace(' ','')
#$input=$input -replace('[','')
$Servers =$string.Split(",")
$plainText = "dumypassword"
$secureString = ConvertTo-SecureString $plainText -AsPlainText -Force
cd 'E:\CV_Scripts\VSA_Adhoc_Backup\CVPowershellSDK-master'
$Jobs = @()
Connect-CVServer -Server server1 -User testuser -Password $secureString
$(foreach ($i in $Servers)
{
$Job = $null
        $Vm = Get-CVVirtualMachine -Name $($i)
        $pseudoClient = (get-cvclient -id $Vm.pseudoClient.clientId).get_Item("clientName")
        $backupJob = Backup-CVVirtualMachine -Name $Vm.client.clientName -ClientName $pseudoClient
        $Job = [PSCustomObject]@{
                VMName = $Vm.Name
                JobId = $backupJob.jobIds
        }    
        $Jobs += $Job
    })
    $Jobs

Userlevel 3
Badge +6

From what we are seeing the SDK calls are working but they are not able to find the client, hence the error message here:

Get-CVClient: client not found having id [0]

Is is possible to validate that the client information is properly getting into the script?

Badge +6

The same script is working if I use it directly from powershell but for some reason not working when I use it through workflow. How to validate if the client information is properly getting into script in workflow? Is there something we are missing on the script whi h needs to be added in the script in order to use it in workflow 

Userlevel 3
Badge +6

Is there a way to log or write to a file the client information that get client id is trying to look up?

Reply