Skip to content

Commit

Permalink
SqlServerDsc: Minor style cleanup of code and typos (dsccommunity#1018)
Browse files Browse the repository at this point in the history
- Changes to SqlSetup
  - Added PSSA rule 'PSUseDeclaredVarsMoreThanAssignments' override in the
    function Set-TargetResource for the variable $global:DSCMachineStatus.
  - Style cleanup in helper function ConvertTo-Decimal.
- Changes to SqlServerDscHelper
  - Fixed typo in comment-base help for helper function Test-AvailabilityReplicaSeedingModeAutomatic.
- Changes to SqlServerMemory
  - Minor style cleanup of code in tests.
- Changes to SqlDatabaseDefaultLocation
  - Minor style cleanup of code in tests.
- Changes to SqlServerMemory
  - Minor style cleanup of code in tests.
- Changes to SqlAGListener
  - Fixed typo in comment-based help.
- Changes to SqlAGReplica
  - Minor code style cleanup. Removed unused variable and instead piped the cmdlet
    Join-SqlAvailabilityGroup to Out-Null.
- Changes to SqlScript
  - Fixed minor typos in comment-based help.
- Changes to SqlAGReplica
  - Fixed minor typos in comment-based help.
- Changes to SqlServerConfiguration
  - Fixed minor typos in comment-based help.
- Changes to SqlScript
  - Fixed minor typos in comment-based help.
- Changes to SqlAGReplica
  - Fixed minor typos in comment.
- Changes to SqlServerMaxDop
  - Minor style - Changes in the helper function Get-SqlDscDynamicMaxDop.
- Changes to SqlServerLogin
  - Minor code style cleanup.
  - Removed unused variable and instead piped the helper function Connect-SQL to
    Out-Null.
- Changes to SqlServerMemory
  - Minor style cleanup of code in tests.
- Changes to SqlServerPermission
  - Fixed minor typos in comment-based help.
- Changes to SqlServerReplication
  - Fixed minor typos in verbose messages.
- Changes to SqlServiceAccount
  - Minor code style cleanup.
- Changes to SqlWindowsFirewall
  - Fixed minor typos in comment-based help.
  - Minor code style cleanup.
  • Loading branch information
johlju authored Jan 14, 2018
1 parent bc8241a commit 4f09846
Show file tree
Hide file tree
Showing 16 changed files with 117 additions and 77 deletions.
37 changes: 34 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@
- Updated the security token for AppVeyor status badge in README.md. When we
renamed the repository the security token was changed
([issue #1012](https://github.com/PowerShell/SqlServerDsc/issues/1012)).
- Fixed typo in comment-base help for helper function Test-AvailabilityReplicaSeedingModeAutomatic.
- Changes to SqlAGListener
- Fixed typo in comment-based help.
- Changes to SqlAGReplica
- Minor code style cleanup. Removed unused variable and instead piped the cmdlet
Join-SqlAvailabilityGroup to Out-Null.
- Fixed minor typos in comment-based help.
- Fixed minor typos in comment.
- Changes to SqlAlias
- Fixed issue where exception was thrown if reg keys did not exist
([issue #949](https://github.com/PowerShell/SqlServerDsc/issues/949)).
Expand All @@ -52,9 +60,7 @@
- Changes to SqlDatabaseDefaultLocation
- Refactor integration tests slightly to improve run time performance
([issue #1001](https://github.com/PowerShell/SqlServerDsc/issues/1001)).
- Changes to SqlServerEndpoint
- Updated README.md with links to the examples
([issue #504](https://github.com/PowerShell/SqlServerDsc/issues/504)).
- Minor style cleanup of code in tests.
- Changes to SqlRS
- Replaced Get-WmiObject with Get-CimInstance to fix Script Analyzer warnings
([issue #264](https://github.com/PowerShell/SqlServerDsc/issues/264)).
Expand All @@ -65,8 +71,26 @@
([issue #634](https://github.com/PowerShell/SqlServerDsc/issues/634)).
- Refactor integration tests slightly to improve run time performance
([issue #1001](https://github.com/PowerShell/SqlServerDsc/issues/1001)).
- Changes to SqlServerConfiguration
- Fixed minor typos in comment-based help.
- Changes to SqlServerEndpoint
- Updated README.md with links to the examples
([issue #504](https://github.com/PowerShell/SqlServerDsc/issues/504)).
- Changes to SqlServerLogin
- Added integration tests ([issue #748](https://github.com/PowerShell/SqlServerDsc/issues/748)).
- Minor code style cleanup.
- Removed unused variable and instead piped the helper function Connect-SQL to
Out-Null.
- Changes to SqlServerMaxDop
- Minor style changes in the helper function Get-SqlDscDynamicMaxDop.
- Changes to SqlServerMemory
- Minor style cleanup of code in tests.
- Changes to SqlServerPermission
- Fixed minor typos in comment-based help.
- Changes to SqlServerReplication
- Fixed minor typos in verbose messages.
- Changes to SqlScript
- Fixed minor typos in comment-based help.
- Changes to SqlServerNetwork
- Added sysadmin account parameter usage to the examples.
- Changes to SqlServerReplication
Expand All @@ -83,6 +107,7 @@
- Added a read-only parameter ServiceAccountName so that the service account
name is correctly returned as a string ([issue #982](https://github.com/PowerShell/SqlServerDsc/issues/982)).
- Added integration tests ([issue #980](https://github.com/PowerShell/SqlServerDsc/issues/980)).
- Minor code style cleanup.
- Changes to SqlSetup
- Added parameter `ASServerMode` to support installing Analysis Services in
Multidimensional mode, Tabular mode and PowerPivot mode
Expand All @@ -93,6 +118,12 @@
- Added integration tests for installing a default instance of Database Engine.
- Refactor integration tests slightly to improve run time performance
([issue #1001](https://github.com/PowerShell/SqlServerDsc/issues/1001)).
- Added PSSA rule 'PSUseDeclaredVarsMoreThanAssignments' override in the
function Set-TargetResource for the variable $global:DSCMachineStatus.
- Style cleanup in helper function ConvertTo-Decimal.
- Changes to SqlWindowsFirewall
- Fixed minor typos in comment-based help.
- Minor code style cleanup.

## 10.0.0.0

Expand Down
4 changes: 2 additions & 2 deletions DSCResources/MSFT_SqlAGListener/MSFT_SqlAGListener.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function Get-TargetResource
The name of the availability group to which the availability group listener is or will be connected.
.PARAMETER IpAddress
The IP address used for the availability group listener, in the format 192.168.10.45/255.255.252.0. If using DCHP, set to the first IP-address of the DHCP subnet, in the format 192.168.8.1/255.255.252.0. Must be valid in the cluster-allowed IP range.
The IP address used for the availability group listener, in the format 192.168.10.45/255.255.252.0. If using DHCP, set to the first IP-address of the DHCP subnet, in the format 192.168.8.1/255.255.252.0. Must be valid in the cluster-allowed IP range.
.PARAMETER Port
The port used for the availability group listener.
Expand Down Expand Up @@ -362,7 +362,7 @@ function Set-TargetResource
The name of the availability group to which the availability group listener is or will be connected.
.PARAMETER IpAddress
The IP address used for the availability group listener, in the format 192.168.10.45/255.255.252.0. If using DCHP, set to the first IP-address of the DHCP subnet, in the format 192.168.8.1/255.255.252.0. Must be valid in the cluster-allowed IP range.
The IP address used for the availability group listener, in the format 192.168.10.45/255.255.252.0. If using DHCP, set to the first IP-address of the DHCP subnet, in the format 192.168.8.1/255.255.252.0. Must be valid in the cluster-allowed IP range.
.PARAMETER Port
The port used for the availability group listener.
Expand Down
10 changes: 5 additions & 5 deletions DSCResources/MSFT_SqlAGReplica/MSFT_SqlAGReplica.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Pare
Hostname of the SQL Server to be configured.
.PARAMETER InstanceName
Name of the SQL instance to be configued.
Name of the SQL instance to be configured.
#>
function Get-TargetResource
{
Expand Down Expand Up @@ -118,7 +118,7 @@ function Get-TargetResource
Hostname of the SQL Server to be configured.
.PARAMETER InstanceName
Name of the SQL instance to be configued.
Name of the SQL instance to be configured.
.PARAMETER PrimaryReplicaServerName
Hostname of the SQL Server where the primary replica is expected to be active. If the primary replica is not found here, the resource will attempt to find the host that holds the primary replica and connect to it.
Expand Down Expand Up @@ -303,7 +303,7 @@ function Set-TargetResource
# Determine if the Availability Group exists on the instance
if ( $availabilityGroup )
{
# Make sure the replia exists on the instance. If the availability group exists, the replica should exist.
# Make sure the replica exists on the instance. If the availability group exists, the replica should exist.
$availabilityGroupReplica = $availabilityGroup.AvailabilityReplicas[$Name]
if ( $availabilityGroupReplica )
{
Expand Down Expand Up @@ -443,7 +443,7 @@ function Set-TargetResource
# Join the Availability Group Replica to the Availability Group
try
{
$joinAvailabilityGroupResults = Join-SqlAvailabilityGroup -Name $AvailabilityGroupName -InputObject $serverObject
Join-SqlAvailabilityGroup -Name $AvailabilityGroupName -InputObject $serverObject | Out-Null
}
catch
{
Expand Down Expand Up @@ -474,7 +474,7 @@ function Set-TargetResource
Hostname of the SQL Server to be configured.
.PARAMETER InstanceName
Name of the SQL instance to be configued.
Name of the SQL instance to be configured.
.PARAMETER PrimaryReplicaServerName
Hostname of the SQL Server where the primary replica is expected to be active. If the primary replica is not found here, the resource will attempt to find the host that holds the primary replica and connect to it.
Expand Down
16 changes: 8 additions & 8 deletions DSCResources/MSFT_SqlScript/MSFT_SqlScript.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ Import-Module -Name (Join-Path -Path (Split-Path -Path (Split-Path -Path $script
.PARAMETER TestFilePath
Path to the T-SQL file that will perform Test action.
Any script that does not throw an error or returns null is evaluated to true.
The cmdlet Invoke-SqlCmd treats T-SQL Print statements as verbose text, and will not cause the test to return false.
The cmdlet Invoke-Sqlcmd treats T-SQL Print statements as verbose text, and will not cause the test to return false.
.PARAMETER Credential
The credentials to authenticate with, using SQL Authentication. To authenticate using Windows Authentication, assign the credentials
to the built-in parameter `PsDscRunAsCredential`. If both parameters `Credential` and `PsDscRunAsCredential` are not assigned,
then SYSTEM account will be used to authenticate using Windows Authentication.
.PARAMETER Variable
Specifies, as a string array, a sqlcmd scripting variable for use in the sqlcmd script, and sets a value for the variable.
Specifies, as a string array, a Invoke-Sqlcmd scripting variable for use in the Invoke-Sqlcmd script, and sets a value for the variable.
Use a Windows PowerShell array to specify multiple variables and their values. For more information how to use this,
please go to the help documentation for [Invoke-Sqlcmd](https://technet.microsoft.com/en-us/library/mt683370.aspx).
Expand Down Expand Up @@ -111,7 +111,7 @@ function Get-TargetResource
.PARAMETER TestFilePath
Path to the T-SQL file that will perform Test action.
Any script that does not throw an error or returns null is evaluated to true.
The cmdlet Invoke-SqlCmd treats T-SQL Print statements as verbose text, and will not cause the test to return false.
The cmdlet Invoke-Sqlcmd treats T-SQL Print statements as verbose text, and will not cause the test to return false.
.PARAMETER Credential
The credentials to authenticate with, using SQL Authentication. To authenticate using Windows Authentication, assign the credentials
Expand All @@ -123,7 +123,7 @@ function Get-TargetResource
In some SQL Server versions there is a bug in Invoke-Sqlcmd where the normal default value 0 (no timeout) is not respected and the default value is incorrectly set to 30 seconds.
.PARAMETER Variable
Specifies, as a string array, a sqlcmd scripting variable for use in the sqlcmd script, and sets a value for the variable.
Specifies, as a string array, a Invoke-Sqlcmd scripting variable for use in the Invoke-Sqlcmd script, and sets a value for the variable.
Use a Windows PowerShell array to specify multiple variables and their values. For more information how to use this,
please go to the help documentation for [Invoke-Sqlcmd](https://technet.microsoft.com/en-us/library/mt683370.aspx).
#>
Expand Down Expand Up @@ -184,7 +184,7 @@ function Set-TargetResource
.PARAMETER TestFilePath
Path to the T-SQL file that will perform Test action.
Any script that does not throw an error or returns null is evaluated to true.
The cmdlet Invoke-SqlCmd treats T-SQL Print statements as verbose text, and will not cause the test to return false.
The cmdlet Invoke-Sqlcmd treats T-SQL Print statements as verbose text, and will not cause the test to return false.
.PARAMETER Credential
The credentials to authenticate with, using SQL Authentication. To authenticate using Windows Authentication, assign the credentials
Expand All @@ -196,7 +196,7 @@ function Set-TargetResource
In some SQL Server versions there is a bug in Invoke-Sqlcmd where the normal default value 0 (no timeout) is not respected and the default value is incorrectly set to 30 seconds.
.PARAMETER Variable
Specifies, as a string array, a sqlcmd scripting variable for use in the sqlcmd script, and sets a value for the variable.
Specifies, as a string array, a Invoke-Sqlcmd scripting variable for use in the Invoke-Sqlcmd script, and sets a value for the variable.
Use a Windows PowerShell array to specify multiple variables and their values. For more information how to use this,
please go to the help documentation for [Invoke-Sqlcmd](https://technet.microsoft.com/en-us/library/mt683370.aspx).
Expand Down Expand Up @@ -270,7 +270,7 @@ function Test-TargetResource
Path to SQL script file that will be executed.
.PARAMETER Credential
The credentials to use to authenticate using SQL Authentication. To authenticate using Windows Authentication, assing the credentials
The credentials to use to authenticate using SQL Authentication. To authenticate using Windows Authentication, assign the credentials
to the built-in parameter 'PsDscRunAsCredential'. If both parameters 'Credential' and 'PsDscRunAsCredential' are not assigned, then
the SYSTEM account will be used to authenticate using Windows Authentication.
Expand All @@ -279,7 +279,7 @@ function Test-TargetResource
In some SQL Server versions there is a bug in Invoke-Sqlcmd where the normal default value 0 (no timeout) is not respected and the default value is incorrectly set to 30 seconds.
.PARAMETER Variable
Creates a sqlcmd scripting variable for use in the sqlcmd script, and sets a value for the variable.
Creates a Invoke-Sqlcmd scripting variable for use in the Invoke-Sqlcmd script, and sets a value for the variable.
#>
function Invoke-SqlScript
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Pare
Hostname of the SQL Server to be configured
.PARAMETER InstanceName
Name of the SQL instance to be configued. Default is 'MSSQLSERVER'
Name of the SQL instance to be configured. Default is 'MSSQLSERVER'
.PARAMETER OptionName
The name of the SQL configuration option to be checked
Expand Down Expand Up @@ -84,7 +84,7 @@ function Get-TargetResource
Hostname of the SQL Server to be configured
.PARAMETER InstanceName
Name of the SQL instance to be configued. Default is 'MSSQLSERVER'
Name of the SQL instance to be configured. Default is 'MSSQLSERVER'
.PARAMETER OptionName
The name of the SQL configuration option to be set
Expand Down Expand Up @@ -163,7 +163,7 @@ function Set-TargetResource
Hostname of the SQL Server to be configured
.PARAMETER InstanceName
Name of the SQL instance to be configued. Default is 'MSSQLSERVER'
Name of the SQL instance to be configured. Default is 'MSSQLSERVER'
.PARAMETER OptionName
The name of the SQL configuration option to be tested
Expand Down
4 changes: 2 additions & 2 deletions DSCResources/MSFT_SqlServerLogin/MSFT_SqlServerLogin.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,11 @@ function Test-TargetResource
# If testPassed is still true and a login credential was specified, test the password
if ( $testPassed -and $LoginCredential )
{
$userCred = [System.Management.Automation.PSCredential]::new($Name, $LoginCredential.Password)
$userCredential = [System.Management.Automation.PSCredential]::new($Name, $LoginCredential.Password)

try
{
$serverObject = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName -SetupCredential $userCred
Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName -SetupCredential $userCredential | Out-Null
}
catch
{
Expand Down
16 changes: 8 additions & 8 deletions DSCResources/MSFT_SqlServerMaxDop/MSFT_SqlServerMaxDop.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -292,31 +292,31 @@ function Get-SqlDscDynamicMaxDop
$cimInstanceProc = Get-CimInstance -ClassName Win32_Processor

# init variables
$numProcs = 0
$numCores = 0
$numberOfLogicalProcessors = 0
$numberOfCores = 0

# Loop through returned objects
foreach ($processor in $cimInstanceProc)
{
# increment number of processors
$numProcs += $processor.NumberOfLogicalProcessors
$numberOfLogicalProcessors += $processor.NumberOfLogicalProcessors

# increment number of cores
$numCores += $processor.NumberOfCores
$numberOfCores += $processor.NumberOfCores
}


if ($numProcs -eq 1)
if ($numberOfLogicalProcessors -eq 1)
{
$dynamicMaxDop = [Math]::Round($numCores / 2, [System.MidpointRounding]::AwayFromZero)
$dynamicMaxDop = [Math]::Round($numberOfCores / 2, [System.MidpointRounding]::AwayFromZero)
}
elseif ($numCores -ge 8)
elseif ($numberOfCores -ge 8)
{
$dynamicMaxDop = 8
}
else
{
$dynamicMaxDop = $numCores
$dynamicMaxDop = $numberOfCores
}

$dynamicMaxDop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ function Get-SqlDscDynamicMaxMemory
$numberOfSqlThreads = 0
}

$operatingSystemArchitecture = (Get-CimInstance -ClassName Win32_operatingsystem).OSArchitecture
$operatingSystemArchitecture = (Get-CimInstance -ClassName Win32_OperatingSystem).OSArchitecture

# Find threadStackSize 1MB x86/ 2MB x64/ 4MB IA64
if ($operatingSystemArchitecture -eq '32-bit')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ function Get-SQLServerPermissionSet
Merges an array of any PermissionSet objects into a single PermissionSet.
The though with this helper function si it can be used for any permission set object
because all inheriths from Microsoft.SqlServer.Management.Smo.PermissionSetBase.
because all inherits from Microsoft.SqlServer.Management.Smo.PermissionSetBase.
.PARAMETER Object
An array of strings which should be concatenated to a single PermissionSet object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ function Install-LocalDistributor
$DistributionDB
)

Write-Verbose "Calling InstallDistributor with DistributionDB"
Write-Verbose "Calling method InstallDistributor() with DistributionDB"
$ReplicationServer.InstallDistributor($AdminLinkCredentials.Password, $DistributionDB)
}

Expand All @@ -398,7 +398,7 @@ function Uninstall-Distributor
[System.Boolean]
$UninstallWithForce
)
Write-Verbose 'Calling UnistallDistributor method on ReplicationServer object'
Write-Verbose 'Calling method UninstallDistributor() on ReplicationServer object'
$ReplicationServer.UninstallDistributor($UninstallWithForce)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ function Get-SqlServiceName
# Ensure we got a service definition
if ($serviceTypeDefinition)
{
# Multiple definitions found (thank you SSRS!)
# Multiple definitions found (thank you SQL Server Reporting Services!)
if ($serviceTypeDefinition.Count -gt 0)
{
$serviceNamingScheme = $serviceTypeDefinition | ForEach-Object -Process {
Expand Down
19 changes: 14 additions & 5 deletions DSCResources/MSFT_SqlSetup/MSFT_SqlSetup.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -658,8 +658,16 @@ function Get-TargetResource
#>
function Set-TargetResource
{
# Suppressing this rule because $global:DSCMachineStatus is used to trigger a reboot, either by force or when there are pending changes.
<#
Suppressing this rule because $global:DSCMachineStatus is used to trigger
a reboot, either by force or when there are pending changes.
#>
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidGlobalVars', '')]
<#
Suppressing this rule because $global:DSCMachineStatus is only set,
never used (by design of Desired State Configuration).
#>
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Scope='Function', Target='DSCMachineStatus')]
[CmdletBinding()]
param
(
Expand Down Expand Up @@ -2004,20 +2012,21 @@ function ConvertTo-Decimal
{
[CmdletBinding()]
[OutputType([System.UInt32])]
param(
param
(
[Parameter(Mandatory = $true)]
[System.Net.IPAddress]
$IPAddress
)

$i = 3
$DecimalIP = 0
$decimalIpAddress = 0
$IPAddress.GetAddressBytes() | ForEach-Object {
$DecimalIP += $_ * [Math]::Pow(256,$i)
$decimalIpAddress += $_ * [Math]::Pow(256,$i)
$i--
}

return [UInt32]$DecimalIP
return [System.UInt32] $decimalIpAddress
}

<#
Expand Down
Loading

0 comments on commit 4f09846

Please sign in to comment.