Skip to content

Commit

Permalink
Use correct service account for permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
MichelZ committed Dec 3, 2024
1 parent 35ba44c commit 6d3c59d
Showing 1 changed file with 5 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -222,23 +222,14 @@ steps:
Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\$($_.Value)\MSSQLServer\SuperSocketNetLib" -Name Certificate -Value $certificate.Thumbprint.ToLower()
# Grant read access to Private Key for SQL Service Account
# icacls $machineKeyPath /grant "NT Service\MSSQL`$$($_.Name):R"
icacls $machineKeyPath /grant "NT AUTHORITY\LOCAL SERVICE:R"
if ($($_.Name) -eq "MSSQLSERVER") {
icacls $machineKeyPath /grant "NT Service\MSSQLSERVER:R"
} else {
icacls $machineKeyPath /grant "NT Service\MSSQL`$$($_.Name):R"
}
}
}
}
$serviceName = "${{parameters.instanceName }}"
$InstancePrefix = 'MSSQL$'
if ( "${{parameters.instanceName }}" -ne "MSSQLSERVER" )
{
$serviceName = $InstancePrefix+"${{parameters.instanceName }}"
}
# Get the account running the SQL Server service
$service = Get-CimInstance -ClassName Win32_Service -Filter "Name='$serviceName'"
Write-Output "SQL Server is running under: $($service.StartName)"
displayName: 'Add SQL Certificate [Win]'
condition: ${{parameters.condition }}

Expand Down

0 comments on commit 6d3c59d

Please sign in to comment.