Connecting commserve using powershell

  • 21 September 2022
  • 2 replies

Userlevel 3
Badge +13

Hi Team,


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 ? 


2 replies

Userlevel 1
Badge +5

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, 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.Dictionary[[String],[String]]"
$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 Make sure you select Language: PowerShell-REST Method.

For more details, see the followin thread: 

Hope this helps you!

Badge +1

And to add to LukeBrett, I like to use MS Secrets vault.