bseltz-cohesity / scripts

Cohesity REST API examples in PowerShell and Python
Apache License 2.0
102 stars 41 forks source link

aagFailoverMinder.ps1 script used in post SQL Protection Job #108

Closed amhaats1 closed 1 year ago

amhaats1 commented 1 year ago

I have been using aagFailoverMinder.ps1

in our Protection Jobs as a Post Script so it can perform the INC backup on errors that occur.

It works great if I pass the

-jobName 'ProctectionGroupName'

or even put it in the script itself like

[Parameter()][array]$jobName = 'ProctionGroupName'

Successful Result: Connected! Getting SQL protection run status... NP_SQL_HA_RPO24H_30

however when I try and use the environment variable that the Protection job creates at each run Example: -jobName $env:COHESITY_JOB_NAME

or even put it in the script itself like

[Parameter()][array]$jobName = $env:COHESITY_JOB_NAME,

I get Jobs not found 'NP_SQL_HA_RPO24H_30' Getting SQL protection run status...

It's able to use the variable from what I can tell because 'NP_SQL_HA_RPO24H_30' is the name of the Protection Group I'm running the script against but just not able to complete due to the error

Are there any adjustments I can make to the script? I don't want you to change your script by any means on github. Just looking for maybe a modification I need to do on my side to use the environment variables. I tried changing to a parameter of [string] and that didn't help Example: [Parameter()][string]$jobName = $env:COHESITY_JOB_NAME,

bseltz-cohesity commented 1 year ago

The single quotes in Jobs not found 'NP_SQL_HA_RPO24H_30' are suspicious. Try: -jobName $($env:Cohesity_JOB_NAME).replace("'","")

amhaats1 commented 1 year ago

That Worked!! Thank you again!