Skip to content

Commit 0c894a0

Browse files
authored
Merge pull request #97 from PowerShell/dev
Release of version 2.1.0.0 of xComputerManagement
2 parents e14f337 + 07660e8 commit 0c894a0

33 files changed

+1544
-1214
lines changed

.MetaTestOptIn.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[
2+
"Common Tests - Validate Markdown Files",
3+
"Common Tests - Validate Example Files",
4+
"Common Tests - Validate Module Files",
5+
"Common Tests - Validate Script Files"
6+
]

.codecov.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
codecov:
2+
notify:
3+
require_ci_to_pass: no
4+
# dev should be the baseline for reporting
5+
branch: dev
6+
7+
comment:
8+
layout: "reach, diff"
9+
behavior: default
10+
11+
coverage:
12+
range: 50..80
13+
round: down
14+
precision: 0
15+
16+
status:
17+
project:
18+
default:
19+
# Set the overall project code coverage requirement to 70%
20+
target: 70
21+
patch:
22+
default:
23+
# Set the pull request requirement to not regress overall coverage by more than 5%
24+
# and let codecov.io set the goal for the code changed in the patch.
25+
target: auto
26+
threshold: 5

.github/CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
If you'd like to contribute to this project, please review the [Contribution Guidelines](https://github.com/PowerShell/DscResources/blob/master/CONTRIBUTING.md).

.github/ISSUE_TEMPLATE.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!--
2+
Your feedback and support is greatly appreciated, thanks for contributing!
3+
4+
Please prefix the issue title with the resource name, i.e. 'xComputer: Short description of my issue'
5+
Please provide the following information regarding your issue (place N/A if the fields that don't apply to your issue):
6+
-->
7+
**Details of the scenario you tried and the problem that is occurring:**
8+
9+
**The DSC configuration that is using the resource (as detailed as possible):**
10+
11+
**Version of the Operating System and PowerShell the DSC Target Node is running:**
12+
13+
**Version of the DSC module you're using, or 'dev' if you're using current dev branch:**

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!--
2+
Thanks for submitting a Pull Request (PR) to this project. Your contribution to this project is greatly appreciated!
3+
4+
Please prefix the PR title with the resource name, i.e. 'xComputer: My short description'
5+
If this is a breaking change, then also prefix the PR title with 'BREAKING CHANGE:', i.e. 'BREAKING CHANGE: xComputer: My short description'
6+
7+
To aid community reviewers in reviewing and merging your PR, please take the time to run through the below checklist.
8+
Change to [x] for each task in the task list that applies to this PR.
9+
-->
10+
**Pull Request (PR) description**
11+
<!-- Replace this with a description of your pull request -->
12+
13+
**This Pull Request (PR) fixes the following issues:**
14+
<!-- Replace this with the list of issues or n/a. Use format: Fixes #123 -->
15+
16+
**Task list:**
17+
- [ ] Change details added to Unreleased section of CHANGELOG.md?
18+
- [ ] Added/updated documentation, comment-based help and descriptions in .schema.mof files where appropriate?
19+
- [ ] Examples appropriately updated?
20+
- [ ] New/changed code adheres to [Style Guidelines](https://github.com/PowerShell/DscResources/blob/master/StyleGuidelines.md)?
21+
- [ ] [Unit and (optional) Integration tests](https://github.com/PowerShell/DscResources/blob/master/TestsGuidelines.md) created/updated where possible?

.markdownlint.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"default": true,
3+
"MD029": {
4+
"style": "one"
5+
},
6+
"MD013": true,
7+
"MD024": true,
8+
"MD034": true,
9+
"no-hard-tabs": true
10+
}

.vscode/settings.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Place your settings in this file to overwrite default and user settings.
2+
{
3+
"powershell.codeFormatting.openBraceOnSameLine": false,
4+
"powershell.codeFormatting.newLineAfterOpenBrace": false,
5+
"powershell.codeFormatting.newLineAfterCloseBrace": true,
6+
"powershell.codeFormatting.whitespaceBeforeOpenBrace": true,
7+
"powershell.codeFormatting.whitespaceBeforeOpenParen": true,
8+
"powershell.codeFormatting.whitespaceAroundOperator": true,
9+
"powershell.codeFormatting.whitespaceAfterSeparator": true,
10+
"powershell.codeFormatting.ignoreOneLineBlock": false,
11+
"powershell.codeFormatting.preset": "Custom",
12+
"files.trimTrailingWhitespace": true,
13+
"files.insertFinalNewline": true
14+
}

DSCResources/CommonResourceHelper.psm1

Lines changed: 43 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<#
1+
<#
22
.SYNOPSIS
33
Retrieves the localized string data based on the machine's culture.
44
Falls back to en-US strings if the machine's culture is not supported.
@@ -48,12 +48,12 @@ function Get-LocalizedData
4848
#>
4949
function Remove-CommonParameter
5050
{
51-
[OutputType([hashtable])]
51+
[OutputType([System.Collections.Hashtable])]
5252
[cmdletbinding()]
5353
param
5454
(
5555
[Parameter(Mandatory = $true)]
56-
[hashtable]
56+
[System.Collections.Hashtable]
5757
$Hashtable
5858
)
5959

@@ -87,25 +87,27 @@ function Test-DscParameterState
8787
[CmdletBinding()]
8888
param
8989
(
90-
[Parameter(Mandatory = $true)]
91-
[hashtable]
90+
[Parameter(Mandatory = $true)]
91+
[System.Collections.Hashtable]
9292
$CurrentValues,
9393

94-
[Parameter(Mandatory = $true)]
94+
[Parameter(Mandatory = $true)]
9595
[object]
9696
$DesiredValues,
97-
97+
98+
[Parameter()]
9899
[string[]]
99100
$ValuesToCheck,
100-
101+
102+
[Parameter()]
101103
[switch]
102104
$TurnOffTypeChecking
103105
)
104106

105107
$returnValue = $true
106108

107109
$types = 'System.Management.Automation.PSBoundParametersDictionary', 'System.Collections.Hashtable', 'Microsoft.Management.Infrastructure.CimInstance'
108-
110+
109111
if ($DesiredValues.GetType().FullName -notin $types)
110112
{
111113
throw ("Property 'DesiredValues' in Test-DscParameterState must be either a Hashtable or CimInstance. Type detected was $($DesiredValues.GetType().FullName)")
@@ -115,13 +117,13 @@ function Test-DscParameterState
115117
{
116118
throw ("If 'DesiredValues' is a CimInstance then property 'ValuesToCheck' must contain a value")
117119
}
118-
120+
119121
$desiredValuesClean = Remove-CommonParameter -Hashtable $DesiredValues
120122

121123
if (-not $ValuesToCheck)
122124
{
123125
$keyList = $desiredValuesClean.Keys
124-
}
126+
}
125127
else
126128
{
127129
$keyList = $ValuesToCheck
@@ -135,19 +137,19 @@ function Test-DscParameterState
135137
}
136138
else
137139
{
138-
$desiredType = [psobject]@{
139-
Name = 'Unknown'
140+
$desiredType = [psobject]@{
141+
Name = 'Unknown'
140142
}
141143
}
142-
144+
143145
if ($null -ne $CurrentValues.$key)
144146
{
145147
$currentType = $CurrentValues.$key.GetType()
146148
}
147149
else
148150
{
149-
$currentType = [psobject]@{
150-
Name = 'Unknown'
151+
$currentType = [psobject]@{
152+
Name = 'Unknown'
151153
}
152154
}
153155

@@ -164,7 +166,7 @@ function Test-DscParameterState
164166
Write-Verbose -Message ('NOTMATCH: PSCredential username mismatch. Current state is {0} and desired state is {1}' -f $CurrentValues.$key.UserName, $desiredValuesClean.$key.UserName)
165167
$returnValue = $false
166168
}
167-
169+
168170
# Assume the string is our username when the matching desired value is actually a credential
169171
if ($currentType.Name -eq 'string' -and $CurrentValues.$key -eq $desiredValuesClean.$key.UserName)
170172
{
@@ -177,10 +179,10 @@ function Test-DscParameterState
177179
$returnValue = $false
178180
}
179181
}
180-
182+
181183
if (-not $TurnOffTypeChecking)
182-
{
183-
if (($desiredType.Name -ne 'Unknown' -and $currentType.Name -ne 'Unknown') -and
184+
{
185+
if (($desiredType.Name -ne 'Unknown' -and $currentType.Name -ne 'Unknown') -and
184186
$desiredType.FullName -ne $currentType.FullName)
185187
{
186188
Write-Verbose -Message "NOTMATCH: Type mismatch for property '$key' Current state type is '$($currentType.Name)' and desired type is '$($desiredType.Name)'"
@@ -193,22 +195,22 @@ function Test-DscParameterState
193195
Write-Verbose -Message "MATCH: Value (type $($desiredType.Name)) for property '$key' does match. Current state is '$($CurrentValues.$key)' and desired state is '$($desiredValuesClean.$key)'"
194196
continue
195197
}
196-
198+
197199
if ($desiredValuesClean.GetType().Name -in 'HashTable', 'PSBoundParametersDictionary')
198200
{
199201
$checkDesiredValue = $desiredValuesClean.ContainsKey($key)
200-
}
202+
}
201203
else
202204
{
203205
$checkDesiredValue = Test-DSCObjectHasProperty -Object $desiredValuesClean -PropertyName $key
204206
}
205-
207+
206208
if (-not $checkDesiredValue)
207209
{
208210
Write-Verbose -Message "MATCH: Value (type $($desiredType.Name)) for property '$key' does match. Current state is '$($CurrentValues.$key)' and desired state is '$($desiredValuesClean.$key)'"
209211
continue
210212
}
211-
213+
212214
if ($desiredType.IsArray)
213215
{
214216
Write-Verbose -Message "Comparing values in property '$key'"
@@ -237,33 +239,33 @@ function Test-DscParameterState
237239
}
238240
else
239241
{
240-
$desiredType = [psobject]@{
242+
$desiredType = [psobject]@{
241243
Name = 'Unknown'
242244
}
243245
}
244-
246+
245247
if ($null -ne $currentArrayValues[$i])
246248
{
247249
$currentType = $currentArrayValues[$i].GetType()
248250
}
249251
else
250252
{
251253
$currentType = [psobject]@{
252-
Name = 'Unknown'
254+
Name = 'Unknown'
253255
}
254256
}
255-
257+
256258
if (-not $TurnOffTypeChecking)
257259
{
258-
if (($desiredType.Name -ne 'Unknown' -and $currentType.Name -ne 'Unknown') -and
260+
if (($desiredType.Name -ne 'Unknown' -and $currentType.Name -ne 'Unknown') -and
259261
$desiredType.FullName -ne $currentType.FullName)
260262
{
261263
Write-Verbose -Message "`tNOTMATCH: Type mismatch for property '$key' Current state type of element [$i] is '$($currentType.Name)' and desired type is '$($desiredType.Name)'"
262264
$returnValue = $false
263265
continue
264266
}
265267
}
266-
268+
267269
if ($desiredArrayValues[$i] -ne $currentArrayValues[$i])
268270
{
269271
Write-Verbose -Message "`tNOTMATCH: Value [$i] (type $($desiredType.Name)) for property '$key' does match. Current state is '$($currentArrayValues[$i])' and desired state is '$($desiredArrayValues[$i])'"
@@ -276,20 +278,20 @@ function Test-DscParameterState
276278
continue
277279
}
278280
}
279-
281+
280282
}
281-
}
282-
else
283+
}
284+
else
283285
{
284286
if ($desiredValuesClean.$key -ne $CurrentValues.$key)
285287
{
286288
Write-Verbose -Message "NOTMATCH: Value (type $($desiredType.Name)) for property '$key' does not match. Current state is '$($CurrentValues.$key)' and desired state is '$($desiredValuesClean.$key)'"
287289
$returnValue = $false
288290
}
289-
290-
}
291+
292+
}
291293
}
292-
294+
293295
Write-Verbose -Message "Result is '$returnValue'"
294296
return $returnValue
295297
}
@@ -308,7 +310,7 @@ function Test-DSCObjectHasProperty
308310
[OutputType([bool])]
309311
param
310312
(
311-
[Parameter(Mandatory = $true)]
313+
[Parameter(Mandatory = $true)]
312314
[object]
313315
$Object,
314316

@@ -317,11 +319,11 @@ function Test-DSCObjectHasProperty
317319
$PropertyName
318320
)
319321

320-
if ($Object.PSObject.Properties.Name -contains $PropertyName)
322+
if ($Object.PSObject.Properties.Name -contains $PropertyName)
321323
{
322324
return [bool] $Object.$PropertyName
323325
}
324-
326+
325327
return $false
326328
}
327329

@@ -377,10 +379,12 @@ function New-InvalidOperationException
377379
[CmdletBinding()]
378380
param
379381
(
382+
[Parameter()]
380383
[ValidateNotNullOrEmpty()]
381384
[String]
382385
$Message,
383386

387+
[Parameter()]
384388
[ValidateNotNull()]
385389
[System.Management.Automation.ErrorRecord]
386390
$ErrorRecord

0 commit comments

Comments
 (0)