murano-conductor/data/templates/agent/scripts/New-SqlServerSystemAccount.ps1
Georgy Okrokvertskhov 30b9bed2fc Added base64 encryption of the script files. Now script files are stored
separately from templates in the ./scripts/ directory.

test_windows_agent.py updated.

Formatting in windows_agent.py fixed.

Tracing and error capturing added to Set-LocalUserPassword.

Function Set-LocalUserPassword removed as it is implemented by workflow
means.

Scripts now stored in one common folder.
Scripts updated from murano-deployment.
Templates updated to reflect new script names.

Workflow template can reference multiple script files. These script
files will be concatinated and encrypted with base64.

Change-Id: Icb3532d2fb724bbb711c06086cb906bde22a380f

Fixed flake8 reported issues.

Change-Id: Icb3532d2fb724bbb711c06086cb906bde22a380f

Fixed test failure after reformatting.

Change-Id: Icb3532d2fb724bbb711c06086cb906bde22a380f

Fixed issues with test. Revert back path selection for scripts folder.
It is reasonable to have an ability to use own folder for custom
workflows so script path is relative to template location.

Change-Id: Icb3532d2fb724bbb711c06086cb906bde22a380f
2013-08-12 11:37:41 -07:00

65 lines
1.7 KiB
PowerShell

trap {
&$TrapHandler
}
function New-SqlServerSystemAccount {
param (
# (REQUIRED) Domain Name
[Parameter(Mandatory=$true)]
[String] $DomainName,
# (REQUIRED) User name who has permissions to create and modify userPassword
# Usually this is the domain administrator '$domainName\Administrator' account
[Parameter(Mandatory=$true)]
[String] $UserName,
# (REQUIRED) Password for that user
[Parameter(Mandatory=$true)]
[String] $UserPassword,
# (REQUIRED) User name for a new account that will be used to run SQL Server
[Parameter(Mandatory=$true)]
[String] $SQLServiceUserName,
# (REQUIRED) Password for that user
[Parameter(Mandatory=$true)]
[String] $SQLServiceUserPassword,
[String] $PrimaryNode = ' '
)
begin {
Show-InvocationInfo $MyInvocation
}
end {
Show-InvocationInfo $MyInvocation -End
}
process {
trap {
&$TrapHandler
}
if ($PrimaryNode.ToLower() -ne ($Env:ComputerName).ToLower()) {
Write-Log "THis function runs on AOAG primary node only."
Write-Log "Exiting."
return
}
Write-Log "Installing 'RSAT-AD-PowerShell' ... "
Add-WindowsFeature RSAT-AD-PowerShell
Import-Module ActiveDirectory
$Creds = New-Credential -UserName "$DomainName\$UserName" -Password "$UserPassword"
Write-Log "Adding new user ..."
$null = New-ADUser `
-Name $SQLServiceUserName `
-AccountPassword $(ConvertTo-SecureString -String $SQLServiceUserPassword -AsPlainText -Force) `
-Credential $Creds `
-ErrorAction 'Stop'
}
}