Guest User

Untitled

a guest
Jun 6th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. Configuration SQLInstall
  2.  
  3. {param (
  4. [Parameter(Mandatory=$true)]
  5. [ValidateNotNullOrEmpty()]
  6. [String]
  7. $PackagePath,
  8.  
  9. [Parameter(Mandatory = $true)]
  10. [System.Management.Automation.PSCredential]
  11. $ServiceAccountCredential
  12.  
  13. )
  14. Import-DscResource –ModuleName PSDesiredStateConfiguration
  15. Import-DSCResource -ModuleName ComputerManagementDsc
  16. Import-DSCResource -ModuleName SqlServerDsc
  17.  
  18. Node $AllNodes.where{ $_.Role.Contains("SQLENGINE") }.NodeName
  19. {
  20.  
  21. Log ParamLog
  22. {
  23. Message = "Running SQLInstall. PackagePath = $PackagePath"
  24. }
  25.  
  26. # Password info here
  27. $password = $using:Node.Service4SQLPassword | ConvertTo-SecureString -asPlainText -Force
  28. $username = $using:Node.Service4SQLAccount
  29. $Credential = New-Object System.Management.Automation.PSCredential($username,$password)
  30.  
  31. SqlServiceAccount SetServiceAccount_DatabaseEngine
  32. {
  33. ServerName = $Node.NodeName
  34. InstanceName = 'MSSQLSERVER'
  35. ServiceType = 'DatabaseEngine'
  36. ServiceAccount = $ServiceAccountCredential
  37. RestartService = $true
  38. Force = $true
  39. DependsOn = "[Script]InstallSQLServer"
  40. }
  41.  
  42. SqlServiceAccount SetServiceAccount_SQLServerAgent
  43. {
  44. ServerName = $Node.NodeName
  45. InstanceName = 'MSSQLSERVER'
  46. ServiceType = 'SQLServerAgent'
  47. ServiceAccount = $ServiceAccountCredential
  48. RestartService = $true
  49. Force = $true
  50. DependsOn = "[Script]InstallSQLServer"
  51. }
  52.  
  53. SqlServiceAccount SetServiceAccount_IntegrationServices
  54. {
  55. ServerName = $Node.NodeName
  56. InstanceName = 'MSSQLSERVER'
  57. ServiceType = 'IntegrationServices'
  58. ServiceAccount = $ServiceAccountCredential
  59. RestartService = $true
  60. Force = $true
  61. DependsOn = "[Script]InstallSQLServer"
  62. }
  63. }}
  64.  
  65. SQLInstall -ConfigurationData C:PowerShell_UserScriptsMyServerData.psd1 `
Add Comment
Please, Sign In to add comment