-
Notifications
You must be signed in to change notification settings - Fork 2
/
CV-RESTAPI-QOperationExecute-DisableAllJobActivity.ps1
81 lines (70 loc) · 2.41 KB
/
CV-RESTAPI-QOperationExecute-DisableAllJobActivity.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# This is messy, please forgive me :<
# Can call either to
# - WebServer: :81/SearchSvc/CVWebService.svc
# - WebConsole: /webconsole/api/
$CVRESTAPIEndpoint = "http://webserver_name_here:81/SearchSvc/CVWebService.svc"
$username = "<username>"
$password = "<password>"
$headers = @{}
$headers["Accept"] = "application/json"
$Body = @{
username = $username
password = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($password))
}
try {
# Login to Commvault REST API
$Result = Invoke-RestMethod -Method POST -Uri "$CVRESTAPIEndpoint/Login" -Headers $headers -Body $($Body | ConvertTo-Json) -ContentType "application/json"
# Save QSDK token
$headers["Authtoken"] = $Result.token
Write-Host "[*] Successful login to" $CVRESTAPIEndpoint
} catch {
Write-Host "Failed to login - received status code" $_.Exception.Response.StatusCode.value__
Write-Host "StatusDesc:" $_.Exception.Response.StatusDescription
Write-Host "errList"
Write-Host $Result.errList
Write-Host "JSON response"
Write-Host $Result
}
# Construct Body
$DisableAllActivity_Body = @{
command = "qoperation execute"
inputRequestXML = @"
<App_SetCommCellPropertiesReq>
<commCellInfo>
<commCellActivityControlInfo>
<activityControlOptions activityType="128" enableAfterADelay="0" enableActivityType="0" />
</commCellActivityControlInfo>
</commCellInfo>
</App_SetCommCellPropertiesReq>
"@
}
$EnableAllActivity_Body = @{
command = "qoperation execute"
inputRequestXML = @"
<App_SetCommCellPropertiesReq>
<commCellInfo>
<commCellActivityControlInfo>
<activityControlOptions activityType="128" enableAfterADelay="0" enableActivityType="1" />
</commCellActivityControlInfo>
</commCellInfo>
</App_SetCommCellPropertiesReq>
"@
}
# Call Workflow
try {
$Result = Invoke-RestMethod -Method POST -Uri "$CVRESTAPIEndpoint/ExecuteQCommand" -Headers $headers -Body $DisableAllActivity_Body
# Sloppy reporting
If ($Result.Response.errorCode == 0) {
Write-Host "[*] Successfully submitted change!"
} else {
Write-Host "[!] Something went wrong"
Write-Host $Result.response
}
} catch {
Write-Host "StatusCode:" $_.Exception.Response.StatusCode.value__
Write-Host "StatusDesc:" $_.Exception.Response.StatusDescription
Write-Host "errList"
Write-Host $Result.errList
Write-Host "Full response"
Write-Host $Result.response
}