Parameterise instance name for backup script
This commit is contained in:
@@ -32,8 +32,8 @@
|
||||
If $true, keep the temporary script and task after completion. Default $false = cleanup.
|
||||
|
||||
.EXAMPLE
|
||||
# Using gMSA
|
||||
.\createSAcreds.ps1 -Domain AD -AccountName rubrikgmsa -AccountType gMSA -SaJsonPath C:\temp\sa.json -OutputXmlPath C:\temp\sa-rbksql.xml
|
||||
# Using gMSA (no need to user $ at end of name)
|
||||
.\createSAcreds.ps1 -Domain AD -AccountName rubrikgmsa -AccountType gMSA -SaJsonPath C:\Rubrik\scripts\sa.json -OutputXmlPath C:\Rubrik\scripts\sa-rbksql.xml
|
||||
|
||||
.EXAMPLE
|
||||
# Using regular service account with password prompt
|
||||
@@ -77,7 +77,7 @@ try {
|
||||
|
||||
# ---- Create the one-shot script that will run under the service account ----
|
||||
$oneShotContent = @"
|
||||
# One-shot script created by create-and-run-one-shot-via-gMSA.ps1
|
||||
# One-shot script created by createSAcreds.ps1
|
||||
# Runs RubrikSecurityCloud command to create service-account file
|
||||
|
||||
# Start transcript for detailed logging
|
||||
@@ -134,7 +134,7 @@ Try {
|
||||
Exit 4
|
||||
}
|
||||
} Catch {
|
||||
Write-Error "Error creating RBK service-account file: `$(`$_.Exception.Message)"
|
||||
Write-Error "Error creating Rubrik service-account file: `$(`$_.Exception.Message)"
|
||||
Write-Error "Full exception: `$(`$_.Exception | Format-List * | Out-String)"
|
||||
Write-Error "Stack trace: `$(`$_.ScriptStackTrace)"
|
||||
Stop-Transcript
|
||||
@@ -156,10 +156,10 @@ Try {
|
||||
# Construct the UserId based on account type
|
||||
if ($AccountType -eq 'gMSA') {
|
||||
$userId = if ([string]::IsNullOrWhiteSpace($Domain)) { "$AccountName`$" } else { "$Domain\$AccountName`$" }
|
||||
$logonType = 'Password' # For gMSA, use Password logon type
|
||||
$logonType = 'Password' # needed even though gMSA uses AD for auth
|
||||
} else {
|
||||
$userId = if ([string]::IsNullOrWhiteSpace($Domain)) { $AccountName } else { "$Domain\$AccountName" }
|
||||
$logonType = 'Password' # For regular service accounts, use Password logon type
|
||||
$logonType = 'Password'
|
||||
}
|
||||
|
||||
# Action: run PowerShell to execute the one-shot script with output redirection
|
||||
@@ -255,7 +255,7 @@ Try {
|
||||
Write-Warning "Log file not found at: $logFile"
|
||||
}
|
||||
|
||||
throw "Scheduled task finished with non-zero LastTaskResult: $lastResult. Check Event Viewer > Applications and Services Logs > Microsoft > Windows > TaskScheduler for details, or review the log output above."
|
||||
throw "Scheduled task finished with non-zero LastTaskResult: $lastResult."
|
||||
}
|
||||
|
||||
# ---- Cleanup ----
|
||||
|
||||
Reference in New Issue
Block a user