Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

Commit

Permalink
Merge pull request #162 from mhendric/PortStyleUpgrades
Browse files Browse the repository at this point in the history
Port Style Upgrades in DscResources Folder from xPSDesiredStateConfiguration
  • Loading branch information
PlagueHO authored Jun 7, 2019
2 parents c1edd1b + 4a7f80d commit 545ad6d
Show file tree
Hide file tree
Showing 23 changed files with 1,358 additions and 1,344 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

* Ports most of the style upgrades from xPSDesiredStateConfiguration that have
been made in files in the DscResources folder.
* Ports fixes for the following issues:
[Issue #505](https://github.com/PowerShell/xPSDesiredStateConfiguration/issues/505)
[Issue #590](https://github.com/PowerShell/xPSDesiredStateConfiguration/issues/590)
Expand Down
38 changes: 20 additions & 18 deletions DscResources/CommonResourceHelper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ function Test-IsNanoServer
param ()

$serverLevelsRegKey = 'HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Server\ServerLevels'

if (Test-Path -Path $serverLevelsRegKey)
{
$serverLevels = Get-ItemProperty -Path $serverLevelsRegKey

if ($serverLevels.NanoServer -eq 1)
{
$isNanoServer = $true
Expand All @@ -27,7 +27,7 @@ function Test-IsNanoServer
{
$isNanoServer = $false
}

return $isNanoServer
}

Expand All @@ -46,7 +46,8 @@ function Test-CommandExists
(
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[System.String] $Name
[System.String]
$Name
)

$command = Get-Command -Name $Name -ErrorAction 'SilentlyContinue'
Expand All @@ -55,13 +56,13 @@ function Test-CommandExists

<#
.SYNOPSIS
Creates and throws an invalid argument exception
Creates and throws an invalid argument exception.
.PARAMETER Message
The message explaining why this error is being thrown
The message explaining why this error is being thrown.
.PARAMETER ArgumentName
The name of the invalid argument that is causing this error to be thrown
The name of the invalid argument that is causing this error to be thrown.
#>
function New-InvalidArgumentException
{
Expand All @@ -80,9 +81,9 @@ function New-InvalidArgumentException
)

$argumentException = New-Object -TypeName 'ArgumentException' `
-ArgumentList @($Message, $ArgumentName)
-ArgumentList @($Message, $ArgumentName)
$newObjectParams = @{
TypeName = 'System.Management.Automation.ErrorRecord'
TypeName = 'System.Management.Automation.ErrorRecord'
ArgumentList = @($argumentException, $ArgumentName, 'InvalidArgument', $null)
}
$errorRecord = New-Object @newObjectParams
Expand All @@ -92,13 +93,14 @@ function New-InvalidArgumentException

<#
.SYNOPSIS
Creates and throws an invalid operation exception
Creates and throws an invalid operation exception.
.PARAMETER Message
The message explaining why this error is being thrown
The message explaining why this error is being thrown.
.PARAMETER ErrorRecord
The error record containing the exception that is causing this terminating error
The error record containing the exception that is causing this terminating
error.
#>
function New-InvalidOperationException
{
Expand All @@ -123,18 +125,17 @@ function New-InvalidOperationException
elseif ($null -eq $ErrorRecord)
{
$invalidOperationException = New-Object -TypeName 'InvalidOperationException' `
-ArgumentList @($Message)
-ArgumentList @( $Message )
}
else
{
$invalidOperationException = New-Object -TypeName 'InvalidOperationException' `
-ArgumentList @($Message, $ErrorRecord.Exception)
-ArgumentList @( $Message, $ErrorRecord.Exception )
}

$newObjectParams = @{
TypeName = 'System.Management.Automation.ErrorRecord'
ArgumentList = @( $invalidOperationException.ToString(), 'MachineStateIncorrect',
'InvalidOperation', $null )
TypeName = 'System.Management.Automation.ErrorRecord'
ArgumentList = @( $invalidOperationException.ToString(), 'MachineStateIncorrect', 'InvalidOperation', $null )
}

$errorRecordToThrow = New-Object @newObjectParams
Expand All @@ -147,7 +148,8 @@ function New-InvalidOperationException
Falls back to en-US strings if the machine's culture is not supported.
.PARAMETER ResourceName
The name of the resource as it appears before '.strings.psd1' of the localized string file.
The name of the resource as it appears before '.strings.psd1' of the localized
string file.
For example:
For WindowsOptionalFeature: MSFT_WindowsOptionalFeature
For Service: MSFT_ServiceResource
Expand Down
20 changes: 10 additions & 10 deletions DscResources/GroupSet/GroupSet.schema.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Import-Module -Name $script:resourceSetHelperFilePath
.PARAMETER Ensure
Specifies whether or not the set of groups should exist.
Set this property to Present to create or modify a set of groups.
Set this property to Absent to remove a set of groups.
Expand All @@ -37,25 +37,25 @@ Configuration GroupSet
[CmdletBinding()]
param
(
[Parameter(Mandatory = $true, HelpMessage="The names of the groups for which you want to ensure a specific state.")]
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String[]]
[System.String[]]
$GroupName,

[Parameter( HelpMessage="Indicates whether the groups exist. Set this property to Absent to ensure that the groups do not exist. Setting it to Present (the default value) ensures that the groups exist.")]
[Parameter()]
[ValidateSet('Present', 'Absent')]
[String]
[System.String]
$Ensure,

[Parameter( HelpMessage="Use this property to add members to the existing membership of the group. The value of this property is an array of strings of the form Domain\UserName. If you set this property in a configuration, do not use the Members property. Doing so will generate an error.")]
[String[]]
[Parameter()]
[System.String[]]
$MembersToInclude,

[Parameter( HelpMessage="Use this property to remove members from the existing membership of the groups. The value of this property is an array of strings of the form Domain\UserName. If you set this property in a configuration, do not use the Members property. Doing so will generate an error.")]
[String[]]
[Parameter()]
[System.String[]]
$MembersToExclude,

[Parameter( HelpMessage="The credentials required to access remote resources. Note: This account must have the appropriate Active Directory permissions to add all non-local accounts to the group; otherwise, an error will occur.")]
[Parameter()]
[ValidateNotNullOrEmpty()]
[System.Management.Automation.PSCredential]
[System.Management.Automation.Credential()]
Expand Down
Loading

0 comments on commit 545ad6d

Please sign in to comment.