HI @ptmorris,
I never had an “Unauthorized” message while using PowershellSDKV2. Make sure you are running Feature Release 26 or later. Here’s a sample of the output you get from SDKV2 :
# Output sample
PS C:\Users\Administrator\Documents\WindowsPowerShell> Get-MediaAgent
Description DisplayName Id Name OfflineReason Status Version
----------- ----------- -- ---- ------------- ------ -------
commserve 2 commserve ONLINE 11 SP28.19
PS C:\Users\Administrator\Documents\WindowsPowerShell> Get-ServerGroup
Association Id IsCompanySmartClientGroup IsSyncInProgress Name
----------- -- ------------------------- ---------------- ----
AUTOMATIC 1 False Infrastructure
AUTOMATIC 2 False Proxy Clients
AUTOMATIC 3 False Media Agents
AUTOMATIC 4 False Laptop Clients
Overall, I prefer SDK1 because the output handling is much better, but it has a very limited number of cmdlets. SDK2 is more of a work in progress. It is not really sysadmin friendly. If you have some development skills in PowerShell, you can easily customize the functions.
If you wish to do your own API calls, here’s how you can get a token on your own in PowerShell :
# How to connect and get a token
$headers = New-Object "System.Collections.Generic.Dictionaryc.String],rString]]"
$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.
Hope this helps you in your Commvault PowerShell journey!
I was able to Get-MediaAgent to work. Today a different error from get-virtualmachine, so from what you said seems like these aren’t ready for mainstream use yet. I hope they continue to work on this but doesn’t look like anything new in over 8 months. Guess I am stuck with v1 for now.
Yes I am able to use API as I said, I just prefer the easier Powershell Cmdlets
Thanks for your reply