Hi, I'm new to Commvault and I have a question regarding the "Restore-CVVirtualMachine" PowerShell command. I wanted to make a script that will restore a VM from a backup created in the source VMware vCenter to the destination VMware vCenter using PowerShell. As far as I can see, the "Restore-CVVirtualMachine" command only supports restoring to the same original VMware vCenter.
At the same time, I can easily restore from the Commvault console to the target VMware vCenter.
Does Commvault support recovery from PowerShell to another vCenter?
Thank you for your suggestion, I'm just wondering if it's possible to do this from PowerShell using Commvault PowerShell module commands. Anyway, thanks for pointing out another way that can be used from PowerShell without the Commvaule module commands.
Regarding the REST API example you sent me, could you please point me to an article or example on how to authorize a session with the Commvault server by passing username/password and how can I monitor the restore process to check the current step and whether it's completed successfully or failed?
Thank you for your suggestion, I'm just wondering if it's possible to do this from PowerShell using Commvault PowerShell module commands. Anyway, thanks for pointing out another way that can be used from PowerShell without the Commvaule module commands.
Regarding the REST API example you sent me, could you please point me to an article or example on how to authorize a session with the Commvault server by passing username/password and how can I monitor the restore process to check the current step and whether it's completed successfully or failed?
It really does not work like that.
You authenticate to the commserve and get an auth token, you can then use that token for any requests you have as long as it remains valid.
Here you can see the different parameters you can use. I see there is an out of place option, but I am guessing this is for the same hypervisor as I do not see additional parameters for a different hypervisor client definition. But I am not sure, maybe someone else has experience with this function?
For REST in general you can use this page as a guide: Commvault Rest API - Public Don’t forget to alter the language at the top from cURL to PowerShell
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"$headers.Add("Accept", "application/json")
$headers.Add("Content-Type", "application/json")
$body = "{
`n`"sessionId`": `"QSDK token would be auto set after POST Login is called.`",
`n`"deviceId`": `"{{CommcellName}}`"
`n}"$response = Invoke-RestMethod 'http://WebConsoleHostName/webconsole/api/RenewLoginToken' -Method 'POST' -Headers $headers -Body $body$response | ConvertTo-Json
Restore progress can be monitored by retrieving job summary based on the job id:
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"$headers.Add("Accept", "application/json")
$headers.Add("Authtoken", "QSDK token would be auto set after POST Login is called.")
$response = Invoke-RestMethod 'http://WebConsoleHostName/webconsole/api/Job/432' -Method 'GET' -Headers $headers$response | ConvertTo-Json
First, thank you very much for your help. Yesterday I found the Commvault doc to use Postman and set it up, but I'm getting a response that the username or password is incorrect. Today I used your code and got the same response from PowerShell. If I open http://CVServer/webconsole/api in a browser, the response is "WebService is Running! Tue Aug 30, 2022 10:44:46 AM".
Do I need to allow remote access for the user? The same username and password I used to log in to the desktop console and everything went fine.
We are currently using a trial version of Commvault Express Edition, but will get a license soon. Could this be a limitation of the trial version?
Regarding the Restore-CVVirtualMachine PowerShell command, I tried it before opening a question here. The command suggested restoring (InPlace) a VM from the backup to the original VMware client. I need to restore this virtual machine from a backup to another VMware vCenter, so this command is not suitable for me. I posted the question just in case I'm missing something or if there's another command for this. Looks like the only option is to use the REST API from PowerShell :).
Thanks for pointing me to the site. I encoded my password and noticed a difference when I do it from PowerShell and from the website. The problem was that I was using in PowerShell the following syntax:
[System.Text.Encoding]::Unicode.GetBytes($Text)
which gives me an encoded password that Commvault does not accept.
The correct syntax is:
[System.Text.Encoding]::UTF8.GetBytes($Text)
Now all is fine from PowerShell, I'm getting a response with a token.
We use 3 different kinds of cookies. You can choose which cookies you want to accept. We need basic cookies to make this site work, therefore these are the minimum you can select. Learn more about our cookies.