Closed TheLowox closed 1 week ago
Sounds like you modified the script? Please download the script again and do not modify it. It is working fine
PS C:\scripts\powershell> ./backupNow.ps1 -vip ve4 -username admin -jobName 've4 sql' -backupType 'kFull'
Connected!
Running VE4 SQL...
New Job Run ID: 30:1730979955961171
Job finished with status: Succeeded
I´m running the latest (and obviously unmodified) version of the script.
It has something to do with how the script location is called. If I just call the script "standalone" its working as intended, but if I include it in another script and just reference it, it fails.
During my testing now i figured out if I reference it with an absolute path e.g. C:\scripts\backupNow.ps1
its works fine.
But if I use the variable as relative path e.g. .$PSScriptRoot\backupNow.ps1
it fails with this strange error.
For others e.g. .$PSScriptRoot\restoreSQLDBs.ps1
this works fine.
You need a space between the . and the $PSScriptRoot. . $PSScriptRoot\backupNow.ps1
The space (or not) doesn´t matetr. It has something to do with having imported the "\cohesity-api.ps1" manually before in the same powershell session. I can´t figure out why that would cause such a strange error but if I open a completely new session its working fine with "all versions".
Sorry for bothering, really though it was an issue with how the script handled this kind of variable.
I´m trying to run the following script (latest version of the repo) with the parameters: (also tried being more specific onto just one database object, but this behaves the same way)
backupNow.ps1 -vip "ClusterName" -username "user"-domain local -backupType "kFull" -jobName 'ProtGroupName'
Unfortunately I get the following error and I´m unable to identify a possible cause for it:
` BackupNow.ps1 : The variable cannot be validated because the value kSQL is not a valid value for the environment variable.
It´s correctly connecting to the cluster and finding the ProtectionGroup and figuring out it´s sql server based. (Otherwise I would get other errors)
I couldn´t find any place in the script where It would possible raise the error and any kind of help to troubleshoot it would be highly appreciated. Maybe its just something obvious I´m missing from the documentation.