ps/Modules/Alkami.DevOps.Installation/Private/Set-AppTierGMSAAccounts.ps1
2023-05-30 22:51:22 -07:00

58 lines
2.6 KiB
PowerShell

function Set-AppTierGMSAAccounts {
<#
.SYNOPSIS
Sets App Tier GMS Accounts.
#>
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)]
[Alias("PodGMSAAccount")]
[string]$podGMSAAccountParent
)
$DEFAULTVALUE = "DEFAULTVALUE"
Write-Host "If a warning happens next for [The AppSetting with Key Environment.UserPrefix could not be found], you can ignore that completely"
## We want to set the value if it does not exist, because eventually all machines should have this configured.
## This pairs with Alkami.PowerShell.Configuration\Get-AppServiceAccountName to go in the local web.config or app.config
## Only write it as we consume it.
if ($null -eq (Get-AppSetting -appSettingKey "Environment.UserPrefix")) {
Write-Verbose "Adding Environment.UserPrefix to match this function"
Set-AppSetting -key "Environment.UserPrefix" -Value $podGMSAAccountParent
## This is so we can use this later as ($domain)\(Get-AppSetting -appSettingKey "Environment.UserPrefix").$MatrixLookup[appName]$
## see also Get-AppServiceAccountName
}
$applicationsDictionary = @{
'AuditService' = 'fh\DEFAULTVALUE.audit$';
'BankService' = 'fh\DEFAULTVALUE.bank$';
'ContentService' = 'fh\DEFAULTVALUE.content$';
'CoreService' = 'fh\DEFAULTVALUE.core$';
'ExceptionService' = 'fh\DEFAULTVALUE.exception$';
'MessageCenterService' = 'fh\DEFAULTVALUE.msgctr$';
'NagConfigurationService' = 'fh\DEFAULTVALUE.nag$';
'NotificationService' = 'fh\DEFAULTVALUE.notify$';
'RP-STS' = 'fh\DEFAULTVALUE.rpsts$';
'SchedulerService' = 'fh\DEFAULTVALUE.schedule$';
'SecurityManagementService' = 'fh\DEFAULTVALUE.secmgr$';
'STSConfiguration' = 'fh\DEFAULTVALUE.stsconf$';
'SymConnectMultiplexer' = 'fh\DEFAULTVALUE.multiplx$';
'Alkami Radium Scheduler Service' = 'fh\DEFAULTVALUE.radium$';
'Alkami Nag Service' = 'fh\DEFAULTVALUE.nag$';
}
foreach ($appTierApplication in $appTierApplications) {
$appName = $appTierApplication.Name
$newUserName = $applicationsDictionary[$appName] -replace $DEFAULTVALUE,$podGMSAAccountParent
$appTierApplication.User = $newUserName
Write-Host "$($appTierApplication.Name) : $($appTierApplication.User)"
}
foreach ($appTierService in (Get-AppTierServices)) {
$appName = $appTierService.Name
$newUserName = $applicationsDictionary[$appName] -replace $DEFAULTVALUE,$podGMSAAccountParent
$appTierService.User = $newUserName
Write-Host "$($appTierService.Name) : $($appTierService.User)"
}
}