Commvault / CVPowershellSDK

Developer SDK - Powershell
12 stars 12 forks source link

Unexpected output from Get-CVJob function if the -ClientName parameter is a non-existent client name #19

Closed AnthonyHodges closed 3 years ago

AnthonyHodges commented 3 years ago

PowerShell Module: Commvault.JobManager.psm1 Module Generated on: 5/22/2019 Function: Get-CVJob Parameter: ClientName Parameter Value: 'Any Client Name Not Found In CommCell' Unexpected Output: "INFO: Get-CVClient: client not found having name [Any Client Name Not Found In CommCell]" followed by a summary of all the jobs not filtered out from other parameters Expected Output: "INFO: Get-CVClient: client not found having name [Any Client Name Not Found In CommCell]" only

Code Issue Location: Line 174

            if (-not [String]::IsNullOrEmpty($ClientName)) {
                $clientObj = Get-CVClient -Client $ClientName
                if ($null -ne $clientObj) { 
                    $sessionObj.requestProps.endpoint += '&clientId=' + $clientObj.clientId
                }
            }

Suggested Edit:

             if (-not [String]::IsNullOrEmpty($ClientName)) {
                $clientObj = Get-CVClient -Client $ClientName
                if ($null -ne $clientObj) { 
                    $sessionObj.requestProps.endpoint += '&clientId=' + $clientObj.clientId
                }
                else {
                    return
                }
            }

Thanks to JMH_ML from Commvault Forums 'http://forum.commvault.com/forums/AddPost.aspx?PostID=67531' who discovered this issue.

ypolishetty commented 3 years ago

@AnthonyHodges This is now fixed with the below pull request. Thanks for reporting. https://github.com/Commvault/CVPowershellSDK/pull/21