Skip to main content

Hi Team,

Greetings! 

instead of Connect-CVServer command from PowerShell to connect commserve. is there a another way where we can connect commvault using PowerShell without providing credentials. 

i want to connect to commserver from PowerShell with token or something ? 

 

Hi @Allan0105,

You will always need to provide credentials to connect to the CommServe (or the Web Console). If you use CVPowershellSDK1, as you are doing now, you will provide credentials like this : Connect-CVServer -Server CommServeName -Credential domain\user.

If you use https://github.com/Commvault/CVPowershellSDKV2, you will need to run the following command: Invoke-SetupLogin -Username "#username" -Password "#base64Encodedpassword" -WebServerURL "http://#csName/webconsole/api"

If you prefer to retrieve a token to connect through the Web Console, here’s an example on how to do it:

# How to connect and get a token

$headers = New-Object "System.Collections.Generic.DictionarynaString],nString]]"
$headers.Add("Accept", "application/json")
$headers.Add("Content-Type", "application/json")

$body = "{`n `"password`": `"Password_in_Base64`",`n `"username`": `"admin`",`n `"timeout`" : 30`n}"

$response = Invoke-RestMethod 'http://WebServerName/webconsole/api/Login' -Method 'POST' -Headers $headers -Body $body
$token = $response.token

Once you have the token, you can issue commands from https://api.commvault.com/#3707251b-cc26-8c00-fb24-d007e6d8d236. Make sure you select Language: PowerShell-REST Method.

For more details, see the followin thread: 

Hope this helps you!


And to add to LukeBrett, I like to use MS Secrets vault.  https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.secretmanagement/?view=ps-modules


Reply