Open Gvangeystelen opened 1 year ago
UPDATE : I got this working with the following workaround, : use solely the Rubrik API for these 2 cmdlets
Hopefully this is helpful for someone with the same issue: $serviceAccountId $secret $cluster
values are omitted for obvious reasons
Import-Module Rubrik
$serviceAccountId=""
$secret=""
$cluster=""
$body = @{
serviceAccountId = $serviceAccountId
secret = $secret
}
$bodyJson = $body | ConvertTo-Json
$sessionURL = "https://$cluster/api/v1/service_account/session"
$Uri = [System.Uri]$sessionURL
$rubrikSession = Invoke-RestMethod -Method POST -Uri $Uri -Body $bodyJson -ContentType $type -SkipCertificateCheck
$rubrikSessionHeader = @{'Authorization' = "Bearer $($rubrikSession.token)"}
$rubrikConnection = @{
api = 1
server = $cluster
token = $rubrikSession.token
header = @{
'Authorization' = "Bearer $($rubrikSession.token)"
}
}
#Get ManagedVolume properties
$ManagedVolume = Get-RubrikManagedVolume -name 'SQLBackups_XXX'
$ManagedVolumeId = $ManagedVolume.ID
#Check for propertyvalue that is true when MangedVolume is open
$Open=$ManagedVolume.PSobject.Properties | Where-Object {$_.Name -like "isWritable"}
# If open close the volume, else open the volume
if($Open.Value -eq "True")
{
$sessionURLCloseManagedVolume = "https://$cluster/api/v1/managed_volume/$ManagedVolumeId/end_snapshot"
$UriClose = [System.Uri]$sessionURLCloseManagedVolume
$bodyCloseJson =
@'
{
"expiryDurationInMinutes": 0,
"ownerId": "string",
"refId": "string"
},
"isAsync": true
}
'@
$rubrikSessionCloseManagedVolumeSnapshot = Invoke-RestMethod -Method POST -Uri $UriClose -Body $bodyCloseJson -ContentType $type -Headers $rubrikSessionHeader -SkipCertificateCheck
}else
{
#Open the specified managed volume for read/write operations
$sessionURLOpenManagedVolume = "https://$cluster/api/v1/managed_volume/$ManagedVolumeId/begin_snapshot"
$UriOpen = [System.Uri]$sessionURLOpenManagedVolume
$bodyOpenJson =
@'
{
"expiryDurationInMinutes": 0,
"ownerId": "string",
"refId": "string"
},
"isAsync": true
}
'@
$rubrikSessionOpenManagedVolumeSnapshot = Invoke-RestMethod -Method POST -Uri $UriOpen -Body $bodyOpenJson -ContentType $type -Headers $rubrikSessionHeader -SkipCertificateCheck
}
Disconnect-Rubrik -Confirm:$false
bug is still active - the solution provided by [Gvangeystelen] worked for me. many thanks
Current Behavior:
In Powershell 5 both cmdlets (Stop-RubrikManagedVolumeSnapshot & Start-RubrikManagedVolumeSnapshot) work without any issues.
To prepare for the switch to Rubrik Service accounts (instead of AD accounts) and the upgrade to latest Rubrik version we are modifying our Powershell scripts to work on Powershell 7. (This is a prerequisite for latest Rubrik version apparently.)
log in to Rubrik cluster (via service account and secret) works without issues, once authenticated I can also use Get-RubrikManagedVolume and get the properties back.
If I pipe this output to the Stop-RubrikManagedVolumeSnapshot cmdlet I get an error, likewise if I fill in the -id parameter manually
Expected Behavior: Be able to stop or start a managed volume snapshot.
Steps to Reproduce:
Please provide detailed steps for reproducing the issue.
Context: