commit fb053900493fe8701c5d3c51f6f014ad9734e3e0 Author: James Pattinson Date: Mon Sep 8 12:41:16 2025 +0100 first commit diff --git a/monthlySnap.ps1 b/monthlySnap.ps1 new file mode 100644 index 0000000..6aa816c --- /dev/null +++ b/monthlySnap.ps1 @@ -0,0 +1,90 @@ +########################################################################## +# +# Add a new SSO Group to an existing RSC Tenant Org. +# Created by Rubrik PS for Keylane, June 2024 +# +# Must be run with a Global service account. It reads in the current details +# of the Organisation, adds the new SSO group and runs the UpdateOrg mutation. +# +# Requires RubrikSecurityCloud module to be installed and working against +# a Global Service Account with Administrator rights. +# +# set service account like this +# Set-RscServiceAccountFile sa.json -OutputFilePath Global.xml +# +# Example invocation +# .\create_ssogroup.ps1 -SSOGroup "TestCustomerSSO" -TenantName "keylanetest" +# +# v0.2 Initial Release +# +########################################################################## + +param ( + [Parameter(Mandatory=$True, + HelpMessage="Name of SLA to query")] + [string]$sourceSla, + + [Parameter(Mandatory=$True, + HelpMessage="Name of SLA to trigger")] + [string]$triggerSla +) + +$GlobalSAFile = "C:\Rubrik\james.xml" + +########################### +# Script begins +########################### + +$ErrorActionPreference = 'Stop' + +Import-Module RubrikSecurityCloud + +Connect-Rsc -ServiceAccountFile $GlobalSAFile + +Write-Host "INFO: Getting Tenant details" + +$srcSla = Get-RscSla -Name $sourceSla +if (-not $srcSla) { + Write-Error "ERROR: No source SLA found with name '$sourceSla'. Exiting script." + Disconnect-Rsc + exit 1 +} + +$monthlySla = Get-RscSla -Name $triggerSla +if (-not $monthlySla) { + Write-Error "ERROR: No monthly SLA found with name '$triggerSla'. Exiting script." + Disconnect-Rsc + exit 1 +} + +$query = New-RscQuery -GqlQuery protectedObjectsConnection +$query.Var.slaIds = @($srcSla.Id) +$query.var.filter = @(Get-RscType -Name Filter) +$query.var.filter[0].field = "IS_RELIC" +$query.var.filter[0].Texts = "false" + +$protectedObjects = $query.invoke() + +$protectedObjects.Nodes | ForEach-Object { + + + Write-Host "Triggering Backup for Name: $($_.Name), Id: $($_.Id)" + + $oracleDb = Get-RscOracleDatabase -name "example" + + $query = New-RscMutation -GqlMutation takeOnDemandOracleDatabaseSnapshot + $query.Var.input = Get-RscType -Name TakeOnDemandOracleDatabaseSnapshotInput -InitialProperties config.baseOnDemandSnapshotConfig + $query.Var.input.id = $_.Id + $query.Var.input.Config.forceFullSnapshot = $false + $query.Var.input.Config.baseOnDemandSnapshotConfig.slaId = $monthlySla.id + $query.Field = Get-RscType -Name AsyncRequestStatus -InitialProperties id + $result = $query.Invoke() + + Write-Host "Backup triggered for Name: $($_.Name), Id: $result.Id" + +} + + + + +Disconnect-Rsc \ No newline at end of file