From 7db2ffcca8298b2aeed4928e138511036cffefd8 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Mon, 24 Jul 2017 21:43:43 +0200 Subject: [PATCH] xSQLServer: Opt-in for script files common tests (#708) - Opt-in for script files common tests (issue #707). - Removed Byte Order Mark (BOM) from the files; DSCClusterSqlBuild.ps1, DSCFCISqlBuild.ps1, DSCSqlBuild.ps1, DSCSQLBuildEncrypted.ps1, SQLPush_SingleServer.ps1, 1-AddAvailabilityGroupListenerWithSameNameAsVCO.ps1, 2-AddAvailabilityGroupListenerWithDifferentNameAsVCO.ps1, 3-RemoveAvailabilityGroupListenerWithSameNameAsVCO.ps1, 4-RemoveAvailabilityGroupListenerWithDifferentNameAsVCO.ps1, 5-AddAvailabilityGroupListenerUsingDHCPWithDefaultServerSubnet.ps1, 6-AddAvailabilityGroupListenerUsingDHCPWithSpecificSubnet.ps1, 2-ConfigureInstanceToEnablePriorityBoost.ps1, 1-CreateEndpointWithDefaultValues.ps1, 2-CreateEndpointWithSpecificPortAndIPAddress.ps1, 3-RemoveEndpoint.ps1, 1-AddConnectPermission.ps1, 2-RemoveConnectPermission.ps1, 3-AddConnectPermissionToAlwaysOnPrimaryAndSecondaryReplicaEachWithDifferentSqlServiceAccounts.ps1, 4-RemoveConnectPermissionToAlwaysOnPrimaryAndSecondaryReplicaEachWithDifferentSqlServiceAccounts.ps1, 1-MakeSureEndpointIsStarted.ps1, 2-MakeSureEndpointIsStopped.ps1, 1-EnableTcpIpWithStaticPort.ps1, 2-EnableTcpIpWithDynamicPort.ps1, 1-AddServerPermissionForLogin.ps1, 2-RemoveServerPermissionForLogin.ps1, 1-ConfigureInstanceAsDistributor.ps1, 2-ConfigureInstanceAsPublisher.ps1, 1-WaitForASingleClusterGroup.ps1, 2-WaitForMultipleClusterGroups.ps1. --- .MetaTestOptIn.json | 5 +- CHANGELOG.md | 19 +++ Examples/DSCClusterSqlBuild.ps1 | 152 +++++++++--------- Examples/DSCFCISqlBuild.ps1 | 66 ++++---- Examples/DSCSQLBuildEncrypted.ps1 | 82 +++++----- Examples/DSCSqlBuild.ps1 | 58 +++---- ...labilityGroupListenerWithSameNameAsVCO.ps1 | 2 +- ...ityGroupListenerWithDifferentNameAsVCO.ps1 | 2 +- ...labilityGroupListenerWithSameNameAsVCO.ps1 | 2 +- ...ityGroupListenerWithDifferentNameAsVCO.ps1 | 2 +- ...stenerUsingDHCPWithDefaultServerSubnet.ps1 | 2 +- ...oupListenerUsingDHCPWithSpecificSubnet.ps1 | 2 +- ...ConfigureInstanceToEnablePriorityBoost.ps1 | 2 +- .../1-CreateEndpointWithDefaultValues.ps1 | 2 +- ...teEndpointWithSpecificPortAndIPAddress.ps1 | 2 +- .../xSQLServerEndpoint/3-RemoveEndpoint.ps1 | 2 +- .../1-AddConnectPermission.ps1 | 2 +- .../2-RemoveConnectPermission.ps1 | 2 +- ...icaEachWithDifferentSqlServiceAccounts.ps1 | 2 +- ...icaEachWithDifferentSqlServiceAccounts.ps1 | 2 +- .../1-MakeSureEndpointIsStarted.ps1 | 2 +- .../2-MakeSureEndpointIsStopped.ps1 | 2 +- .../1-EnableTcpIpWithStaticPort.ps1 | 2 +- .../2-EnableTcpIpWithDynamicPort.ps1 | 2 +- .../1-AddServerPermissionForLogin.ps1 | 2 +- .../2-RemoveServerPermissionForLogin.ps1 | 2 +- .../1-ConfigureInstanceAsDistributor.ps1 | 2 +- .../2-ConfigureInstanceAsPublisher.ps1 | 2 +- .../1-WaitForASingleClusterGroup.ps1 | 2 +- .../2-WaitForMultipleClusterGroups.ps1 | 2 +- Examples/SQLPush_SingleServer.ps1 | 24 +-- 31 files changed, 237 insertions(+), 217 deletions(-) diff --git a/.MetaTestOptIn.json b/.MetaTestOptIn.json index 14fef1d02..862a4ab72 100644 --- a/.MetaTestOptIn.json +++ b/.MetaTestOptIn.json @@ -1,4 +1,5 @@ [ "Common Tests - Validate Markdown Files", - "Common Tests - Validate Module Files" -] + "Common Tests - Validate Module Files", + "Common Tests - Validate Script Files" + ] diff --git a/CHANGELOG.md b/CHANGELOG.md index 9062e0be5..750518f7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,25 @@ MSFT\_xSQLServerNetwork.psm1, MSFT\_xSQLServerPermission.psm1, MSFT\_xSQLServerReplication.psm1, MSFT\_xSQLServerScript.psm1, SQLPSStub.psm1, SQLServerStub.psm1. + - Opt-in for script files common tests ([issue #707](https://github.com/PowerShell/xFailOverCluster/issues/707)). + - Removed Byte Order Mark (BOM) from the files; DSCClusterSqlBuild.ps1, + DSCFCISqlBuild.ps1, DSCSqlBuild.ps1, DSCSQLBuildEncrypted.ps1, + SQLPush_SingleServer.ps1, 1-AddAvailabilityGroupListenerWithSameNameAsVCO.ps1, + 2-AddAvailabilityGroupListenerWithDifferentNameAsVCO.ps1, + 3-RemoveAvailabilityGroupListenerWithSameNameAsVCO.ps1, + 4-RemoveAvailabilityGroupListenerWithDifferentNameAsVCO.ps1, + 5-AddAvailabilityGroupListenerUsingDHCPWithDefaultServerSubnet.ps1, + 6-AddAvailabilityGroupListenerUsingDHCPWithSpecificSubnet.ps1, + 2-ConfigureInstanceToEnablePriorityBoost.ps1, 1-CreateEndpointWithDefaultValues.ps1, + 2-CreateEndpointWithSpecificPortAndIPAddress.ps1, 3-RemoveEndpoint.ps1, + 1-AddConnectPermission.ps1, 2-RemoveConnectPermission.ps1, + 3-AddConnectPermissionToAlwaysOnPrimaryAndSecondaryReplicaEachWithDifferentSqlServiceAccounts.ps1, + 4-RemoveConnectPermissionToAlwaysOnPrimaryAndSecondaryReplicaEachWithDifferentSqlServiceAccounts.ps1, + 1-MakeSureEndpointIsStarted.ps1, 2-MakeSureEndpointIsStopped.ps1, + 1-EnableTcpIpWithStaticPort.ps1, 2-EnableTcpIpWithDynamicPort.ps1, + 1-AddServerPermissionForLogin.ps1, 2-RemoveServerPermissionForLogin.ps1, + 1-ConfigureInstanceAsDistributor.ps1, 2-ConfigureInstanceAsPublisher.ps1, + 1-WaitForASingleClusterGroup.ps1, 2-WaitForMultipleClusterGroups.ps1. - Changes to xSQLServerAlwaysOnService - Added resource description in README.md. - Updated parameters descriptions in comment-based help, schema.mof and README.md. diff --git a/Examples/DSCClusterSqlBuild.ps1 b/Examples/DSCClusterSqlBuild.ps1 index 877c2299c..68510a11e 100644 --- a/Examples/DSCClusterSqlBuild.ps1 +++ b/Examples/DSCClusterSqlBuild.ps1 @@ -1,4 +1,4 @@ -#requires -Version 5 +#requires -Version 5 $StartTime = [System.Diagnostics.Stopwatch]::StartNew() Function check-even($num){[bool]!($num%2)} @@ -10,7 +10,7 @@ $cim = New-CimSession -ComputerName $computers [DSCLocalConfigurationManager()] Configuration LCM_Push -{ +{ Param( [string[]]$ComputerName ) @@ -21,7 +21,7 @@ Configuration LCM_Push AllowModuleOverwrite = $True ConfigurationMode = 'ApplyAndAutoCorrect' RefreshMode = 'Push' - RebootNodeIfNeeded = $True + RebootNodeIfNeeded = $True } } } @@ -29,7 +29,7 @@ Configuration LCM_Push foreach ($computer in $computers) { $GUID = (New-Guid).Guid - LCM_Push -ComputerName $Computer -OutputPath $OutputPath + LCM_Push -ComputerName $Computer -OutputPath $OutputPath Set-DSCLocalConfigurationManager -Path $OutputPath -CimSession $computer -Verbose } @@ -50,12 +50,12 @@ Configuration AlwaysOnCluster RebootNodeIfNeeded = $true DebugMode = "All" } - + WindowsFeature "NET" { Ensure = "Present" Name = "NET-Framework-Core" - Source = $Node.NETPath + Source = $Node.NETPath } WindowsFeature "ADTools" @@ -64,7 +64,7 @@ Configuration AlwaysOnCluster Name = "RSAT-AD-PowerShell" Source = $Node.NETPath } - + if($Node.Features) { xSqlServerSetup ($Node.NodeName) @@ -84,16 +84,16 @@ Configuration AlwaysOnCluster SQLTempDBDir = "T:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Data" SQLTempDBLogDir = "L:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Data" SQLBackupDir = "G:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Data" - + DependsOn = '[WindowsFeature]NET' } - + xSqlServerFirewall ($Node.NodeName) { SourcePath = $Node.SourcePath InstanceName = $Node.InstanceName Features = $Node.Features - + DependsOn = ("[xSqlServerSetup]" + $Node.NodeName) } @@ -101,7 +101,7 @@ Configuration AlwaysOnCluster { Ensure = "Present" DynamicAlloc = $True - + DependsOn = ("[xSqlServerSetup]" + $Node.NodeName) } @@ -109,8 +109,8 @@ Configuration AlwaysOnCluster { Ensure = "Present" DynamicAlloc = $true - - DependsOn = ("[xSqlServerSetup]" + $Node.NodeName) + + DependsOn = ("[xSqlServerSetup]" + $Node.NodeName) } } @@ -133,7 +133,7 @@ Configuration AlwaysOnCluster WindowsFeature RSATClusteringPowerShell { Ensure = "Present" - Name = "RSAT-Clustering-PowerShell" + Name = "RSAT-Clustering-PowerShell" DependsOn = "[WindowsFeature]FailoverFeature" } @@ -151,16 +151,16 @@ Configuration AlwaysOnCluster Name = $Node.ClusterName StaticIPAddress = $Node.ClusterIPAddress DomainAdministratorCredential = $Node.InstallerServiceAccount - + DependsOn = “[WindowsFeature]RSATClusteringCmdInterface” } xSQLServerAlwaysOnService($Node.Nodename) { Ensure = "Present" - + DependsOn = ("[xCluster]ensureCreated"),("[xSqlServerSetup]" + $Node.NodeName) - } - + } + xSQLServerEndpoint($Node.Nodename) { Ensure = "Present" @@ -169,7 +169,7 @@ Configuration AlwaysOnCluster EndPointName = "Hadr_endpoint" DependsOn = ("[xSqlServerSetup]" + $Node.NodeName) } - + xSQLAOGroupEnsure($Node.Nodename) { Ensure = "Present" @@ -181,7 +181,7 @@ Configuration AlwaysOnCluster PsDscRunAsCredential = $Node.InstallerServiceAccount DependsOn = ("[xSQLServerEndpoint]" + $Node.NodeName),("[xSQLServerAlwaysOnService]" + $Node.NodeName),("[WindowsFeature]ADTools") } - } + } Node $AllNodes.Where{$_.Role -eq "ReplicaServerNode" }.NodeName { # Set LCM to reboot if needed @@ -193,14 +193,14 @@ Configuration AlwaysOnCluster RebootNodeIfNeeded = $true DebugMode = "All" } - + WindowsFeature "NET" { Ensure = "Present" Name = "NET-Framework-Core" - Source = $Node.NETPath + Source = $Node.NETPath } - + if($Node.Features) { xSqlServerSetup ($Node.NodeName) @@ -220,16 +220,16 @@ Configuration AlwaysOnCluster SQLTempDBDir = "T:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Data" SQLTempDBLogDir = "L:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Data" SQLBackupDir = "G:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Data" - + DependsOn = '[WindowsFeature]NET' } - + xSqlServerFirewall ($Node.NodeName) { SourcePath = $Node.SourcePath InstanceName = $Node.InstanceName Features = $Node.Features - + DependsOn = ("[xSqlServerSetup]" + $Node.NodeName) } @@ -237,74 +237,74 @@ Configuration AlwaysOnCluster { Ensure = "Present" DynamicAlloc = $True - + DependsOn = ("[xSqlServerSetup]" + $Node.NodeName) } xSQLServerMaxDop($Node.Nodename) { Ensure = "Present" DynamicAlloc = $true - - DependsOn = ("[xSqlServerSetup]" + $Node.NodeName) + + DependsOn = ("[xSqlServerSetup]" + $Node.NodeName) } - + } - + WindowsFeature FailoverFeature { Ensure = "Present" Name = "Failover-clustering" - + DependsOn = ("[xSqlServerSetup]" + $Node.NodeName) } - + WindowsFeature RSATClusteringPowerShell { Ensure = "Present" - Name = "RSAT-Clustering-PowerShell" - + Name = "RSAT-Clustering-PowerShell" + DependsOn = "[WindowsFeature]FailoverFeature" } - + WindowsFeature RSATClusteringMgmt { Ensure = "Present" Name = "RSAT-Clustering-Mgmt" - + DependsOn = "[WindowsFeature]FailoverFeature" } - + WindowsFeature RSATClusteringCmdInterface { Ensure = "Present" Name = "RSAT-Clustering-CmdInterface" - + DependsOn = "[WindowsFeature]RSATClusteringPowerShell" } - - xWaitForCluster waitForCluster - { - Name = $Node.ClusterName - RetryIntervalSec = 10 + + xWaitForCluster waitForCluster + { + Name = $Node.ClusterName + RetryIntervalSec = 10 RetryCount = 6 - + DependsOn = ("[xSqlServerSetup]" + $Node.NodeName) - } - - xCluster joinCluster - { - Name = $Node.ClusterName - StaticIPAddress = $Node.ClusterIPAddress + } + + xCluster joinCluster + { + Name = $Node.ClusterName + StaticIPAddress = $Node.ClusterIPAddress DomainAdministratorCredential = $Node.InstallerServiceAccount - - DependsOn = "[xWaitForCluster]waitForCluster" + + DependsOn = "[xWaitForCluster]waitForCluster" } xSQLServerAlwaysOnService($Node.Nodename) { Ensure = "Present" - + DependsOn = ("[xCluster]joinCluster"),("[xSqlServerSetup]" + $Node.NodeName) - } + } xSQLServerEndpoint($Node.Nodename) { Ensure = "Present" @@ -313,16 +313,16 @@ Configuration AlwaysOnCluster EndPointName = "Hadr_endpoint" DependsOn = ("[xSqlServerSetup]" + $Node.NodeName) } - + xWaitForAvailabilityGroup waitforAG - { - Name = "MyAG" - RetryIntervalSec = 20 + { + Name = "MyAG" + RetryIntervalSec = 20 RetryCount = 6 - + DependsOn = (“[xSQLServerEndpoint]" +$Node.Nodename),(“[xSQLServerAlwaysOnService]" +$Node.Nodename) - } - + } + xSQLAOGroupJoin ($Node.Nodename) { Ensure = "Present" @@ -332,7 +332,7 @@ Configuration AlwaysOnCluster DependsOn = ("[xWaitForAvailabilityGroup]waitforAG") } - + } } $ConfigurationData = @{ @@ -344,8 +344,8 @@ $ConfigurationData = @{ NETPath = "\\ohdc9000\SQLAutoBuilds\SQL2014\WindowsServer2012R2\sources\sxs" SourcePath = "\\ohdc9000\SQLAutoBuilds\SQL2014\" InstallerServiceAccount = Get-Credential -UserName CORP\AutoSvc -Message "Credentials to Install SQL Server" - AdminAccount = "Corp\user1" - ClusterName = "DevCluster" + AdminAccount = "Corp\user1" + ClusterName = "DevCluster" ClusterIPAddress = "10.0.75.199/24" } ) @@ -359,16 +359,16 @@ ForEach ($computer in $computers) { NodeName = $computer InstanceName = "MSSQLSERVER" Features = "SQLENGINE,IS,SSMS,ADV_SSMS" - Role = "PrimaryClusterNode" + Role = "PrimaryClusterNode" } } - else + else { $ConfigurationData.AllNodes += @{ NodeName = $computer InstanceName = "MSSQLSERVER" Features = "SQLENGINE,IS,SSMS,ADV_SSMS" - Role = "ReplicaServerNode" + Role = "ReplicaServerNode" } } $Destination = "\\"+$computer+"\\c$\Program Files\WindowsPowerShell\Modules" @@ -382,14 +382,14 @@ AlwaysOnCluster -ConfigurationData $ConfigurationData -OutputPath $OutputPath #Push################################ -Workflow StartConfigs -{ +Workflow StartConfigs +{ param([string[]]$computers, [System.string] $Path) - - foreach –parallel ($Computer in $Computers) + + foreach –parallel ($Computer in $Computers) { - + Start-DscConfiguration -ComputerName $Computer -Path $Path -Verbose -Wait -Force } } @@ -400,10 +400,10 @@ $StartTime.Elapsed ############Validate############## <# -Workflow TestConfigs -{ +Workflow TestConfigs +{ param([string[]]$computers) - foreach -parallel ($Computer in $Computers) + foreach -parallel ($Computer in $Computers) { Write-verbose "$Computer :" test-dscconfiguration -ComputerName $Computer diff --git a/Examples/DSCFCISqlBuild.ps1 b/Examples/DSCFCISqlBuild.ps1 index 82a4e38bb..928963efa 100644 --- a/Examples/DSCFCISqlBuild.ps1 +++ b/Examples/DSCFCISqlBuild.ps1 @@ -1,16 +1,16 @@ -#requires -Version 5 +#requires -Version 5 $computers = 'OHSQL9034N1','OHSQL9034N2','OHSQL9034N3' $OutputPath = 'F:\DSCConfig' Configuration FCISQL { Import-DscResource –Module PSDesiredStateConfiguration - Import-DscResource -Module xSQLServer + Import-DscResource -Module xSQLServer Import-DscResource -Module xFailoverCluster - + Node $AllNodes.NodeName { - + # Set LCM to reboot if needed LocalConfigurationManager { @@ -40,7 +40,7 @@ Configuration FCISQL WindowsFeature RSATClusteringPowerShell { Ensure = "Present" - Name = "RSAT-Clustering-PowerShell" + Name = "RSAT-Clustering-PowerShell" } WindowsFeature RSATClusteringCmdInterface @@ -92,31 +92,31 @@ Configuration FCISQL DependsOn = "[xCluster]CLDBx" } - + } If ($node.Role -eq "ReplicaServerNode" ) { - xWaitForCluster waitForCluster - { - Name = $Node.ClusterName - RetryIntervalSec = 10 + xWaitForCluster waitForCluster + { + Name = $Node.ClusterName + RetryIntervalSec = 10 RetryCount = 20 - } - - xCluster joinCluster - { - Name = $Node.ClusterName - StaticIPAddress = $Node.ClusterIPAddress + } + + xCluster joinCluster + { + Name = $Node.ClusterName + StaticIPAddress = $Node.ClusterIPAddress DomainAdministratorCredential = $Node.InstallerServiceAccount - - DependsOn = "[xWaitForCluster]waitForCluster" + + DependsOn = "[xWaitForCluster]waitForCluster" } } If ($node.Role -eq "PrimaryServerNode") { - + WaitForAll "SqlPrep" - { + { NodeName = @($computers) ResourceName = "[xSQLServerFailoverClusterSetup]PrepareMSSQLSERVER" PsDscRunAsCredential = $Node.InstallerServiceAccount @@ -137,13 +137,13 @@ Configuration FCISQL SQLSysAdminAccounts = $Node.AdminAccount PsDscRunAsCredential = $Node.InstallerServiceAccount - + DependsOn = @( "[WaitForAll]SqlPrep", "[xClusterDisk]iSCSI" ) } - } + } } } @@ -161,30 +161,30 @@ $ConfigurationData = @{ InstallerServiceAccount = $InstallerServiceAccount SQLServiceAccount = $InstallerServiceAccount AdminAccount = "CORP\Administrator" - ClusterName = "CLDBx6" + ClusterName = "CLDBx6" ClusterIPAddress = "10.0.75.55" FailoverClusterNetworkName = "CLSCDB6" } )} ForEach ($computer in $computers) { - + if($firstComputer -eq $computer) { $ConfigurationData.AllNodes += @{ NodeName = $computer InstanceName = "MSSQLSERVER" Features = "SQLENGINE" - Role = "PrimaryServerNode" + Role = "PrimaryServerNode" } } - else + else { $ConfigurationData.AllNodes += @{ NodeName = $computer InstanceName = "MSSQLSERVER" Features = "SQLENGINE" - Role = "ReplicaServerNode" + Role = "ReplicaServerNode" } } $Destination = "\\"+$computer+"\\c$\Program Files\WindowsPowerShell\Modules" @@ -193,20 +193,20 @@ $ConfigurationData = @{ Copy-Item 'C:\Program Files\WindowsPowerShell\Modules\xFailoverCluster' -Destination $Destination -Recurse -Force Copy-Item 'C:\Program Files\WindowsPowerShell\Modules\xSqlServer' -Destination $Destination -Recurse -Force } - + FCISQL -ConfigurationData $ConfigurationData -OutputPath $OutputPath -Workflow StartConfigs -{ +Workflow StartConfigs +{ param([string[]]$computers, [System.string] $Path) - - foreach –parallel ($Computer in $Computers) + + foreach –parallel ($Computer in $Computers) { - + Start-DscConfiguration -ComputerName $Computer -Path $Path -Verbose -Wait -Force } } diff --git a/Examples/DSCSQLBuildEncrypted.ps1 b/Examples/DSCSQLBuildEncrypted.ps1 index 82582dc32..2038c6e92 100644 --- a/Examples/DSCSQLBuildEncrypted.ps1 +++ b/Examples/DSCSQLBuildEncrypted.ps1 @@ -1,4 +1,4 @@ -#requires -Version 5 +#requires -Version 5 $StartTime = [System.Diagnostics.Stopwatch]::StartNew() $computers = 'OHSQL9012' @@ -10,24 +10,24 @@ $cim = New-CimSession -ComputerName $computers Function check-even($num){[bool]!($num%2)} -Function Get-Cert -{ - Param - ( - [System.String]$RemoteMachine, - [System.String]$SaveLocation = "F:\publicKeys" - ) +Function Get-Cert +{ + Param + ( + [System.String]$RemoteMachine, + [System.String]$SaveLocation = "F:\publicKeys" + ) if (!(test-path $SaveLocation)) { new-item -path $SaveLocation -type Directory } - $CertStore = New-Object System.Security.Cryptography.X509Certificates.X509Store -ArgumentList "\\$($RemoteMachine)\My", "LocalMachine" - $CertStore.Open('ReadOnly') - $certificate = $CertStore.Certificates | Where-Object {$_.EnhancedKeyUsageList.friendlyName -eq "Document Encryption"} - [byte[]]$Bytes = $certificate.Export('Cert') - [string]$SaveLiteralPath = "$SaveLocation\$RemoteMachine.$env:UserDNSDomain.cer" - Remove-Item -Path $SaveLiteralPath -Force -ErrorAction Ignore - Set-Content -Path $SaveLiteralPath -Value $Bytes -Encoding Byte -Force | out-null + $CertStore = New-Object System.Security.Cryptography.X509Certificates.X509Store -ArgumentList "\\$($RemoteMachine)\My", "LocalMachine" + $CertStore.Open('ReadOnly') + $certificate = $CertStore.Certificates | Where-Object {$_.EnhancedKeyUsageList.friendlyName -eq "Document Encryption"} + [byte[]]$Bytes = $certificate.Export('Cert') + [string]$SaveLiteralPath = "$SaveLocation\$RemoteMachine.$env:UserDNSDomain.cer" + Remove-Item -Path $SaveLiteralPath -Force -ErrorAction Ignore + Set-Content -Path $SaveLiteralPath -Value $Bytes -Encoding Byte -Force | out-null } foreach ($computer in $computers) @@ -38,8 +38,8 @@ foreach ($computer in $computers) Get-cert -RemoteMachine $env:COMPUTERNAME -SaveLocation $KeyPath [DSCLocalConfigurationManager()] -Configuration LCM_Reboot_CentralConfig -{ +Configuration LCM_Reboot_CentralConfig +{ Param( [string[]]$ComputerName ) @@ -52,10 +52,10 @@ Configuration LCM_Reboot_CentralConfig RefreshFrequencyMins = 30 ConfigurationModeFrequencyMins = 15 RefreshMode = "Push" - AllowModuleOverwrite = $true - RebootNodeIfNeeded = $True + AllowModuleOverwrite = $true + RebootNodeIfNeeded = $True ConfigurationMode = 'ApplyAndAutoCorrect' - } + } } } #LCM_Reboot_CentralConfig -OutputPath $OutputPath @@ -63,7 +63,7 @@ Configuration LCM_Reboot_CentralConfig foreach ($computer in $computers) { $GUID = (New-Guid).Guid - LCM_Reboot_CentralConfig -ComputerName $Computer -OutputPath $OutputPath + LCM_Reboot_CentralConfig -ComputerName $Computer -OutputPath $OutputPath Set-DSCLocalConfigurationManager -Path $OutputPath -CimSession $cim –Verbose } @@ -71,7 +71,7 @@ Configuration SQLBuild { Import-DscResource –Module PSDesiredStateConfiguration Import-DscResource -Module xSQLServer - + Node $AllNodes.NodeName { LocalConfigurationManager @@ -83,7 +83,7 @@ Configuration SQLBuild { Ensure = "Present" Name = "NET-Framework-Core" - Source = $Node.NETPath + Source = $Node.NETPath } if($Features -ne "") @@ -111,7 +111,7 @@ Configuration SQLBuild SourcePath = $Node.SourcePath InstanceName = $Node.InstanceName Features = $Node.Features - + DependsOn = ("[xSqlServerSetup]" + $Node.NodeName) } @@ -119,15 +119,15 @@ Configuration SQLBuild { Ensure = "Present" DynamicAlloc = $True - + DependsOn = ("[xSqlServerSetup]" + $Node.NodeName) } xSQLServerMaxDop($Node.Nodename) { Ensure = "Present" DynamicAlloc = $true - - DependsOn = ("[xSqlServerSetup]" + $Node.NodeName) + + DependsOn = ("[xSqlServerSetup]" + $Node.NodeName) } } } @@ -142,9 +142,9 @@ $ConfigurationData = @{ NETPath = "\\ohdc9000\SQLBuilds\SQLAutoInstall\WIN2012R2\sxs" SourcePath = "\\ohdc9000\SQLAutoBuilds\SQL2014" InstallerServiceAccount = Get-Credential -UserName CORP\AutoSvc -Message "Credentials to Install SQL Server" - AdminAccount = "CORP\user1" + AdminAccount = "CORP\user1" # For build server encryption - CertificateFile =(Get-PfxCertificate -FilePath "$KeyPath\$env:COMPUTERNAME.$env:USERDNSDOMAIN.cer").Thumbprint + CertificateFile =(Get-PfxCertificate -FilePath "$KeyPath\$env:COMPUTERNAME.$env:USERDNSDOMAIN.cer").Thumbprint } ) @@ -154,12 +154,12 @@ ForEach ($computer in $computers) { $ConfigurationData.AllNodes += @{ NodeName = $computer InstanceName = "MSSQLSERVER" - Features = "SQLENGINE,IS,SSMS,ADV_SSMS" + Features = "SQLENGINE,IS,SSMS,ADV_SSMS" CertificateFile = "$KeyPath\$computer.$env:USERDNSDOMAIN.cer" - Thumbprint = (Get-PfxCertificate -FilePath "$KeyPath\$computer.$env:USERDNSDOMAIN.cer").Thumbprint + Thumbprint = (Get-PfxCertificate -FilePath "$KeyPath\$computer.$env:USERDNSDOMAIN.cer").Thumbprint } - - + + $Destination = "\\"+$computer+"\\c$\Program Files\WindowsPowerShell\Modules" if (Test-Path "$Destination\xSqlServer"){Remove-Item -Path "$Destination\xSqlServer"-Recurse -Force} Copy-Item 'C:\Program Files\WindowsPowerShell\Modules\xSqlServer' -Destination $Destination -Recurse -Force @@ -168,13 +168,13 @@ ForEach ($computer in $computers) { SQLBuild -ConfigurationData $ConfigurationData -OutputPath $OutputPath -Workflow StartConfigs -{ +Workflow StartConfigs +{ param([string[]]$computers, [System.string] $Path) - - foreach –parallel ($Computer in $Computers) - { + + foreach –parallel ($Computer in $Computers) + { Start-DscConfiguration -ComputerName $Computer -Path $Path -Verbose -Wait -Force } } @@ -183,10 +183,10 @@ StartConfigs -Computers $computers -Path $OutputPath #Ttest <# -Workflow TestConfigs -{ +Workflow TestConfigs +{ param([string[]]$computers) - foreach -parallel ($Computer in $Computers) + foreach -parallel ($Computer in $Computers) { Write-verbose "$Computer :" test-dscconfiguration -ComputerName $Computer diff --git a/Examples/DSCSqlBuild.ps1 b/Examples/DSCSqlBuild.ps1 index d3e4478bb..360db5c55 100644 --- a/Examples/DSCSqlBuild.ps1 +++ b/Examples/DSCSqlBuild.ps1 @@ -1,4 +1,4 @@ -#requires -Version 5 +#requires -Version 5 $StartTime = [System.Diagnostics.Stopwatch]::StartNew() $computers = 'OHSQL9015' @@ -9,7 +9,7 @@ Function check-even($num){[bool]!($num%2)} [DSCLocalConfigurationManager()] Configuration LCM_Push -{ +{ Param( [string[]]$ComputerName ) @@ -20,7 +20,7 @@ Configuration LCM_Push AllowModuleOverwrite = $True ConfigurationMode = 'ApplyAndAutoCorrect' RefreshMode = 'Push' - RebootNodeIfNeeded = $True + RebootNodeIfNeeded = $True } } } @@ -28,7 +28,7 @@ Configuration LCM_Push foreach ($computer in $computers) { $GUID = (New-Guid).Guid - LCM_Push -ComputerName $Computer -OutputPath $OutputPath + LCM_Push -ComputerName $Computer -OutputPath $OutputPath Set-DSCLocalConfigurationManager -Path $OutputPath -CimSession $computer -Verbose } @@ -36,11 +36,11 @@ Configuration SQLBuild { Import-DscResource –ModuleName PSDesiredStateConfiguration Import-DscResource -ModuleName xSQLServer - + Node $AllNodes.NodeName { - + # Set LCM to reboot if needed LocalConfigurationManager { @@ -50,14 +50,14 @@ Configuration SQLBuild RebootNodeIfNeeded = $true DebugMode = "All" } - + WindowsFeature "NET" { Ensure = "Present" Name = "NET-Framework-Core" - Source = $Node.NETPath + Source = $Node.NETPath } - + WindowsFeature "ADTools" { Ensure = "Present" @@ -84,16 +84,16 @@ Configuration SQLBuild SQLTempDBDir = "T:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Data" SQLTempDBLogDir = "L:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Data" SQLBackupDir = "G:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Data" - + DependsOn = '[WindowsFeature]NET' } - + xSqlServerFirewall ($Node.NodeName) { SourcePath = $Node.SourcePath InstanceName = $Node.InstanceName Features = $Node.Features - + DependsOn = ("[xSqlServerSetup]" + $Node.NodeName) } @@ -101,18 +101,18 @@ Configuration SQLBuild { Ensure = "Present" DynamicAlloc = $True - + DependsOn = ("[xSqlServerSetup]" + $Node.NodeName) } xSQLServerMaxDop($Node.Nodename) { Ensure = "Present" DynamicAlloc = $true - - DependsOn = ("[xSqlServerSetup]" + $Node.NodeName) + + DependsOn = ("[xSqlServerSetup]" + $Node.NodeName) } } - + xSQLServerEndpoint($Node.Nodename) { Ensure = "Present" @@ -121,8 +121,8 @@ Configuration SQLBuild EndPointName = "Hadr_endpoint" DependsOn = ("[xSqlServerSetup]" + $Node.NodeName) } - - } + + } } $ConfigurationData = @{ AllNodes = @( @@ -133,7 +133,7 @@ $ConfigurationData = @{ NETPath = "\\ohdc9000\SQLBuilds\SQLAutoInstall\WIN2012R2\sxs" SourcePath = "\\ohdc9000\SQLAutoBuilds\SQL2014\" InstallerServiceAccount = Get-Credential -UserName CORP\AutoSvc -Message "Credentials to Install SQL Server" - AdminAccount = "CORP\user1" + AdminAccount = "CORP\user1" } ) } @@ -142,9 +142,9 @@ ForEach ($computer in $computers) { $ConfigurationData.AllNodes += @{ NodeName = $computer InstanceName = "MSSQLSERVER" - Features = "SQLENGINE,IS,SSMS,ADV_SSMS" + Features = "SQLENGINE,IS,SSMS,ADV_SSMS" } - + $Destination = "\\"+$computer+"\\c$\Program Files\WindowsPowerShell\Modules" if (Test-Path "$Destination\xSqlServer"){Remove-Item -Path "$Destination\xSqlServer"-Recurse -Force} Copy-Item 'C:\Program Files\WindowsPowerShell\Modules\xSqlServer' -Destination $Destination -Recurse -Force @@ -154,14 +154,14 @@ SQLBuild -ConfigurationData $ConfigurationData -OutputPath $OutputPath #Push################################ -Workflow StartConfigs -{ +Workflow StartConfigs +{ param([string[]]$computers, [System.string] $Path) - - foreach –parallel ($Computer in $Computers) + + foreach –parallel ($Computer in $Computers) { - + Start-DscConfiguration -ComputerName $Computer -Path $Path -Verbose -Wait -Force } } @@ -170,10 +170,10 @@ StartConfigs -Computers $computers -Path $OutputPath #Ttest -Workflow TestConfigs -{ +Workflow TestConfigs +{ param([string[]]$computers) - foreach -parallel ($Computer in $Computers) + foreach -parallel ($Computer in $Computers) { Write-verbose "$Computer :" test-dscconfiguration -ComputerName $Computer diff --git a/Examples/Resources/xSQLServerAvailabilityGroupListener/1-AddAvailabilityGroupListenerWithSameNameAsVCO.ps1 b/Examples/Resources/xSQLServerAvailabilityGroupListener/1-AddAvailabilityGroupListenerWithSameNameAsVCO.ps1 index 3b9c3d94a..716ffe119 100644 --- a/Examples/Resources/xSQLServerAvailabilityGroupListener/1-AddAvailabilityGroupListenerWithSameNameAsVCO.ps1 +++ b/Examples/Resources/xSQLServerAvailabilityGroupListener/1-AddAvailabilityGroupListenerWithSameNameAsVCO.ps1 @@ -1,4 +1,4 @@ -<# +<# .EXAMPLE This example will add an Availability Group listener with the same name as the cluster role VCO. #> diff --git a/Examples/Resources/xSQLServerAvailabilityGroupListener/2-AddAvailabilityGroupListenerWithDifferentNameAsVCO.ps1 b/Examples/Resources/xSQLServerAvailabilityGroupListener/2-AddAvailabilityGroupListenerWithDifferentNameAsVCO.ps1 index e3a1842eb..5e79872a0 100644 --- a/Examples/Resources/xSQLServerAvailabilityGroupListener/2-AddAvailabilityGroupListenerWithDifferentNameAsVCO.ps1 +++ b/Examples/Resources/xSQLServerAvailabilityGroupListener/2-AddAvailabilityGroupListenerWithDifferentNameAsVCO.ps1 @@ -1,4 +1,4 @@ -<# +<# .EXAMPLE This example will add an Availability Group listener with a different than the cluster role VCO. #> diff --git a/Examples/Resources/xSQLServerAvailabilityGroupListener/3-RemoveAvailabilityGroupListenerWithSameNameAsVCO.ps1 b/Examples/Resources/xSQLServerAvailabilityGroupListener/3-RemoveAvailabilityGroupListenerWithSameNameAsVCO.ps1 index fad376844..fb73e9322 100644 --- a/Examples/Resources/xSQLServerAvailabilityGroupListener/3-RemoveAvailabilityGroupListenerWithSameNameAsVCO.ps1 +++ b/Examples/Resources/xSQLServerAvailabilityGroupListener/3-RemoveAvailabilityGroupListenerWithSameNameAsVCO.ps1 @@ -1,4 +1,4 @@ -<# +<# .EXAMPLE This example will remove an Availability Group listener with a different name than cluster role VCO. #> diff --git a/Examples/Resources/xSQLServerAvailabilityGroupListener/4-RemoveAvailabilityGroupListenerWithDifferentNameAsVCO.ps1 b/Examples/Resources/xSQLServerAvailabilityGroupListener/4-RemoveAvailabilityGroupListenerWithDifferentNameAsVCO.ps1 index 6c545faa6..a7c53b455 100644 --- a/Examples/Resources/xSQLServerAvailabilityGroupListener/4-RemoveAvailabilityGroupListenerWithDifferentNameAsVCO.ps1 +++ b/Examples/Resources/xSQLServerAvailabilityGroupListener/4-RemoveAvailabilityGroupListenerWithDifferentNameAsVCO.ps1 @@ -1,4 +1,4 @@ -<# +<# .EXAMPLE This example will remove an Availability Group listener with the same name as the cluster role VCO. #> diff --git a/Examples/Resources/xSQLServerAvailabilityGroupListener/5-AddAvailabilityGroupListenerUsingDHCPWithDefaultServerSubnet.ps1 b/Examples/Resources/xSQLServerAvailabilityGroupListener/5-AddAvailabilityGroupListenerUsingDHCPWithDefaultServerSubnet.ps1 index 6d9ae6796..78fb04002 100644 --- a/Examples/Resources/xSQLServerAvailabilityGroupListener/5-AddAvailabilityGroupListenerUsingDHCPWithDefaultServerSubnet.ps1 +++ b/Examples/Resources/xSQLServerAvailabilityGroupListener/5-AddAvailabilityGroupListenerUsingDHCPWithDefaultServerSubnet.ps1 @@ -1,4 +1,4 @@ -<# +<# .EXAMPLE This example will add an Availability Group listener using DHCP on the default server subnet. #> diff --git a/Examples/Resources/xSQLServerAvailabilityGroupListener/6-AddAvailabilityGroupListenerUsingDHCPWithSpecificSubnet.ps1 b/Examples/Resources/xSQLServerAvailabilityGroupListener/6-AddAvailabilityGroupListenerUsingDHCPWithSpecificSubnet.ps1 index 09de5f0a3..e43ce5b84 100644 --- a/Examples/Resources/xSQLServerAvailabilityGroupListener/6-AddAvailabilityGroupListenerUsingDHCPWithSpecificSubnet.ps1 +++ b/Examples/Resources/xSQLServerAvailabilityGroupListener/6-AddAvailabilityGroupListenerUsingDHCPWithSpecificSubnet.ps1 @@ -1,4 +1,4 @@ -<# +<# .EXAMPLE This example will add an Availability Group listener using DHCP with a specific subnet. #> diff --git a/Examples/Resources/xSQLServerConfiguration/2-ConfigureInstanceToEnablePriorityBoost.ps1 b/Examples/Resources/xSQLServerConfiguration/2-ConfigureInstanceToEnablePriorityBoost.ps1 index 3bba761a3..b673cfd0f 100644 --- a/Examples/Resources/xSQLServerConfiguration/2-ConfigureInstanceToEnablePriorityBoost.ps1 +++ b/Examples/Resources/xSQLServerConfiguration/2-ConfigureInstanceToEnablePriorityBoost.ps1 @@ -1,4 +1,4 @@ -<# +<# .EXAMPLE This example shows how to configure two SQL Server instances on the same server to have the setting 'priority boost' enabled. .NOTES diff --git a/Examples/Resources/xSQLServerEndpoint/1-CreateEndpointWithDefaultValues.ps1 b/Examples/Resources/xSQLServerEndpoint/1-CreateEndpointWithDefaultValues.ps1 index 55aafd2be..14299925c 100644 --- a/Examples/Resources/xSQLServerEndpoint/1-CreateEndpointWithDefaultValues.ps1 +++ b/Examples/Resources/xSQLServerEndpoint/1-CreateEndpointWithDefaultValues.ps1 @@ -1,4 +1,4 @@ -<# +<# .EXAMPLE This example will add a Database Mirror endpoint, to two instances, using the default values. diff --git a/Examples/Resources/xSQLServerEndpoint/2-CreateEndpointWithSpecificPortAndIPAddress.ps1 b/Examples/Resources/xSQLServerEndpoint/2-CreateEndpointWithSpecificPortAndIPAddress.ps1 index 946fd98fa..035eb7829 100644 --- a/Examples/Resources/xSQLServerEndpoint/2-CreateEndpointWithSpecificPortAndIPAddress.ps1 +++ b/Examples/Resources/xSQLServerEndpoint/2-CreateEndpointWithSpecificPortAndIPAddress.ps1 @@ -1,4 +1,4 @@ -<# +<# .EXAMPLE This example will add a Database Mirror endpoint with a specific listener port and a specific listener IP address. #> diff --git a/Examples/Resources/xSQLServerEndpoint/3-RemoveEndpoint.ps1 b/Examples/Resources/xSQLServerEndpoint/3-RemoveEndpoint.ps1 index 068353629..0c9a958be 100644 --- a/Examples/Resources/xSQLServerEndpoint/3-RemoveEndpoint.ps1 +++ b/Examples/Resources/xSQLServerEndpoint/3-RemoveEndpoint.ps1 @@ -1,4 +1,4 @@ -<# +<# .EXAMPLE This example will remove an Database Mirror endpoint from two instances. diff --git a/Examples/Resources/xSQLServerEndpointPermission/1-AddConnectPermission.ps1 b/Examples/Resources/xSQLServerEndpointPermission/1-AddConnectPermission.ps1 index b3aa1bf86..f99c5dd40 100644 --- a/Examples/Resources/xSQLServerEndpointPermission/1-AddConnectPermission.ps1 +++ b/Examples/Resources/xSQLServerEndpointPermission/1-AddConnectPermission.ps1 @@ -1,4 +1,4 @@ -<# +<# .EXAMPLE This example will add connect permission to the credentials provided in $SqlServiceCredential to the endpoint named 'DefaultMirrorEndpoint'. diff --git a/Examples/Resources/xSQLServerEndpointPermission/2-RemoveConnectPermission.ps1 b/Examples/Resources/xSQLServerEndpointPermission/2-RemoveConnectPermission.ps1 index cd7a20e28..ee327f238 100644 --- a/Examples/Resources/xSQLServerEndpointPermission/2-RemoveConnectPermission.ps1 +++ b/Examples/Resources/xSQLServerEndpointPermission/2-RemoveConnectPermission.ps1 @@ -1,4 +1,4 @@ -<# +<# .EXAMPLE This example will add connect permission to the credentials provided in $SqlServiceCredential to the endpoint named 'DefaultMirrorEndpoint'. diff --git a/Examples/Resources/xSQLServerEndpointPermission/3-AddConnectPermissionToAlwaysOnPrimaryAndSecondaryReplicaEachWithDifferentSqlServiceAccounts.ps1 b/Examples/Resources/xSQLServerEndpointPermission/3-AddConnectPermissionToAlwaysOnPrimaryAndSecondaryReplicaEachWithDifferentSqlServiceAccounts.ps1 index d62e9ebff..e0baf07e0 100644 --- a/Examples/Resources/xSQLServerEndpointPermission/3-AddConnectPermissionToAlwaysOnPrimaryAndSecondaryReplicaEachWithDifferentSqlServiceAccounts.ps1 +++ b/Examples/Resources/xSQLServerEndpointPermission/3-AddConnectPermissionToAlwaysOnPrimaryAndSecondaryReplicaEachWithDifferentSqlServiceAccounts.ps1 @@ -1,4 +1,4 @@ -<# +<# .EXAMPLE This example will add connect permission to both an Always On primary replica and an Always On secondary replica, and where each replica has a different SQL service account. diff --git a/Examples/Resources/xSQLServerEndpointPermission/4-RemoveConnectPermissionToAlwaysOnPrimaryAndSecondaryReplicaEachWithDifferentSqlServiceAccounts.ps1 b/Examples/Resources/xSQLServerEndpointPermission/4-RemoveConnectPermissionToAlwaysOnPrimaryAndSecondaryReplicaEachWithDifferentSqlServiceAccounts.ps1 index b75f43219..a60152c09 100644 --- a/Examples/Resources/xSQLServerEndpointPermission/4-RemoveConnectPermissionToAlwaysOnPrimaryAndSecondaryReplicaEachWithDifferentSqlServiceAccounts.ps1 +++ b/Examples/Resources/xSQLServerEndpointPermission/4-RemoveConnectPermissionToAlwaysOnPrimaryAndSecondaryReplicaEachWithDifferentSqlServiceAccounts.ps1 @@ -1,4 +1,4 @@ -<# +<# .EXAMPLE This example will remove connect permission to both an Always On primary replica and an Always On secondary replica, and where each replica has a different SQL service account. diff --git a/Examples/Resources/xSQLServerEndpointState/1-MakeSureEndpointIsStarted.ps1 b/Examples/Resources/xSQLServerEndpointState/1-MakeSureEndpointIsStarted.ps1 index d6ef85419..cf36a3ae8 100644 --- a/Examples/Resources/xSQLServerEndpointState/1-MakeSureEndpointIsStarted.ps1 +++ b/Examples/Resources/xSQLServerEndpointState/1-MakeSureEndpointIsStarted.ps1 @@ -1,4 +1,4 @@ -<# +<# .EXAMPLE This example will make sure that the endpoint DefaultMirrorEndpoint is in started state in the default instance, if not it will start the endpoint. diff --git a/Examples/Resources/xSQLServerEndpointState/2-MakeSureEndpointIsStopped.ps1 b/Examples/Resources/xSQLServerEndpointState/2-MakeSureEndpointIsStopped.ps1 index 998c33415..1a00c2683 100644 --- a/Examples/Resources/xSQLServerEndpointState/2-MakeSureEndpointIsStopped.ps1 +++ b/Examples/Resources/xSQLServerEndpointState/2-MakeSureEndpointIsStopped.ps1 @@ -1,4 +1,4 @@ -<# +<# .EXAMPLE This example will make sure that the endpoint DefaultMirrorEndpoint is in stopped state, if not it will stop the endpoint. #> diff --git a/Examples/Resources/xSQLServerNetwork/1-EnableTcpIpWithStaticPort.ps1 b/Examples/Resources/xSQLServerNetwork/1-EnableTcpIpWithStaticPort.ps1 index d19e6bf6e..d30b5666c 100644 --- a/Examples/Resources/xSQLServerNetwork/1-EnableTcpIpWithStaticPort.ps1 +++ b/Examples/Resources/xSQLServerNetwork/1-EnableTcpIpWithStaticPort.ps1 @@ -1,4 +1,4 @@ -<# +<# .EXAMPLE This example will enable TCP/IP protocol and set the custom static port to 4509. When RestartService is set to $true the resource will also restart the SQL service. diff --git a/Examples/Resources/xSQLServerNetwork/2-EnableTcpIpWithDynamicPort.ps1 b/Examples/Resources/xSQLServerNetwork/2-EnableTcpIpWithDynamicPort.ps1 index c42159d5e..b2e7b7c98 100644 --- a/Examples/Resources/xSQLServerNetwork/2-EnableTcpIpWithDynamicPort.ps1 +++ b/Examples/Resources/xSQLServerNetwork/2-EnableTcpIpWithDynamicPort.ps1 @@ -1,4 +1,4 @@ -<# +<# .EXAMPLE This example will enable TCP/IP protocol and set the custom static port to 4509. When RestartService is set to $true the resource will also restart the SQL service. diff --git a/Examples/Resources/xSQLServerPermission/1-AddServerPermissionForLogin.ps1 b/Examples/Resources/xSQLServerPermission/1-AddServerPermissionForLogin.ps1 index 5fd120204..05f5a89d9 100644 --- a/Examples/Resources/xSQLServerPermission/1-AddServerPermissionForLogin.ps1 +++ b/Examples/Resources/xSQLServerPermission/1-AddServerPermissionForLogin.ps1 @@ -1,4 +1,4 @@ -<# +<# .EXAMPLE This example will add the server permissions AlterAnyAvailabilityGroup and ViewServerState to the login 'NT AUTHORITY\SYSTEM' and 'NT SERVICE\ClusSvc' to the default instance. diff --git a/Examples/Resources/xSQLServerPermission/2-RemoveServerPermissionForLogin.ps1 b/Examples/Resources/xSQLServerPermission/2-RemoveServerPermissionForLogin.ps1 index c6293ff58..51735bd45 100644 --- a/Examples/Resources/xSQLServerPermission/2-RemoveServerPermissionForLogin.ps1 +++ b/Examples/Resources/xSQLServerPermission/2-RemoveServerPermissionForLogin.ps1 @@ -1,4 +1,4 @@ -<# +<# .EXAMPLE This example will remove the server permissions AlterAnyAvailabilityGroup and ViewServerState from the login 'NT AUTHORITY\SYSTEM'. diff --git a/Examples/Resources/xSQLServerReplication/1-ConfigureInstanceAsDistributor.ps1 b/Examples/Resources/xSQLServerReplication/1-ConfigureInstanceAsDistributor.ps1 index b373b538e..d49aa8f56 100644 --- a/Examples/Resources/xSQLServerReplication/1-ConfigureInstanceAsDistributor.ps1 +++ b/Examples/Resources/xSQLServerReplication/1-ConfigureInstanceAsDistributor.ps1 @@ -1,4 +1,4 @@ -<# +<# .EXAMPLE This example shows how to configure a SQL Server instance as the distributor. #> diff --git a/Examples/Resources/xSQLServerReplication/2-ConfigureInstanceAsPublisher.ps1 b/Examples/Resources/xSQLServerReplication/2-ConfigureInstanceAsPublisher.ps1 index 2498ef856..40a63bfe5 100644 --- a/Examples/Resources/xSQLServerReplication/2-ConfigureInstanceAsPublisher.ps1 +++ b/Examples/Resources/xSQLServerReplication/2-ConfigureInstanceAsPublisher.ps1 @@ -1,4 +1,4 @@ -<# +<# .EXAMPLE This example shows how to configure a SQL Server instance as the publisher. #> diff --git a/Examples/Resources/xWaitForAvailabilityGroup/1-WaitForASingleClusterGroup.ps1 b/Examples/Resources/xWaitForAvailabilityGroup/1-WaitForASingleClusterGroup.ps1 index a249d366d..9b41c8150 100644 --- a/Examples/Resources/xWaitForAvailabilityGroup/1-WaitForASingleClusterGroup.ps1 +++ b/Examples/Resources/xWaitForAvailabilityGroup/1-WaitForASingleClusterGroup.ps1 @@ -1,4 +1,4 @@ -<# +<# .EXAMPLE This example will wait for the cluster role/group 'AGTest1'. #> diff --git a/Examples/Resources/xWaitForAvailabilityGroup/2-WaitForMultipleClusterGroups.ps1 b/Examples/Resources/xWaitForAvailabilityGroup/2-WaitForMultipleClusterGroups.ps1 index 5c5e9e809..fd38fb1df 100644 --- a/Examples/Resources/xWaitForAvailabilityGroup/2-WaitForMultipleClusterGroups.ps1 +++ b/Examples/Resources/xWaitForAvailabilityGroup/2-WaitForMultipleClusterGroups.ps1 @@ -1,4 +1,4 @@ -<# +<# .EXAMPLE This example will wait for both the cluster roles/groups 'AGTest1' and 'AGTest2'. #> diff --git a/Examples/SQLPush_SingleServer.ps1 b/Examples/SQLPush_SingleServer.ps1 index 8596ede98..209598d4f 100644 --- a/Examples/SQLPush_SingleServer.ps1 +++ b/Examples/SQLPush_SingleServer.ps1 @@ -1,4 +1,4 @@ -#requires -Version 5 +#requires -Version 5 $computers = 'OHSQL1016' $OutputPath = 'D:\DSCLocal' $cim = New-CimSession -ComputerName $computers @@ -7,7 +7,7 @@ $cim = New-CimSession -ComputerName $computers [DSCLocalConfigurationManager()] Configuration LCM_Push -{ +{ Param( [string[]]$ComputerName ) @@ -18,7 +18,7 @@ Configuration LCM_Push AllowModuleOverwrite = $True ConfigurationMode = 'ApplyAndAutoCorrect' RefreshMode = 'Push' - RebootNodeIfNeeded = $True + RebootNodeIfNeeded = $True } } } @@ -26,8 +26,8 @@ Configuration LCM_Push foreach ($computer in $computers) { $GUID = (New-Guid).Guid - LCM_Push -ComputerName $Computer -OutputPath $OutputPath - Set-DSCLocalConfigurationManager -Path $OutputPath -CimSession $computer + LCM_Push -ComputerName $Computer -OutputPath $OutputPath + Set-DSCLocalConfigurationManager -Path $OutputPath -CimSession $computer } Configuration SQLSA @@ -47,7 +47,7 @@ Configuration SQLSA { Ensure = "Present" Name = "NET-Framework-Core" - Source = $Node.NETPath + Source = $Node.NETPath } if($Node.Features) @@ -70,7 +70,7 @@ Configuration SQLSA SQLTempDBLogDir = "L:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Data" SQLBackupDir = "G:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Data" } - + xSqlServerFirewall ($Node.NodeName) { DependsOn = ("[xSqlServerSetup]" + $Node.NodeName) @@ -121,7 +121,7 @@ Configuration SQLSA { DatabaseName = "TestDB" RecoveryModel = "Full" - SqlServerInstance ="$($Node.NodeName)\$($Node.SQLInstanceName)" + SqlServerInstance ="$($Node.NodeName)\$($Node.SQLInstanceName)" } xSQLServerDatabaseOwner($Node.Nodename) { @@ -152,7 +152,7 @@ $ConfigurationData = @{ NETPath = "\\ohhv003\SQLBuilds\SQLAutoInstall\WIN2012R2\sxs" SourcePath = "\\ohhv003\SQLBuilds\SQLAutoInstall\SQL2012" InstallerServiceAccount = Get-Credential -UserName Contoso\SQLAutoSvc -Message "Credentials to Install SQL Server" - AdminAccount = "Contoso\sqladmin" + AdminAccount = "Contoso\sqladmin" } ) } @@ -161,7 +161,7 @@ ForEach ($computer in $computers) { $ConfigurationData.AllNodes += @{ NodeName = $computer InstanceName = "MSSQLSERVER" - Features = "SQLENGINE,IS,SSMS,ADV_SSMS" + Features = "SQLENGINE,IS,SSMS,ADV_SSMS" } $Destination = "\\"+$computer+"\\c$\Program Files\WindowsPowerShell\Modules" @@ -171,14 +171,14 @@ ForEach ($computer in $computers) { SQLSA -ConfigurationData $ConfigurationData -OutputPath $OutputPath #Push################################ -foreach($Computer in $Computers) +foreach($Computer in $Computers) { Start-DscConfiguration -ComputerName $Computer -Path $OutputPath -Verbose -Wait -Force } #Ttest -foreach($Computer in $Computers) +foreach($Computer in $Computers) { test-dscconfiguration -ComputerName $Computer }