Skip to content

Commit f0af4cc

Browse files
authored
Merge pull request #172 from PowerShell/dev
Release of version 5.2.0.0 of ComputerManagementDsc
2 parents c0a6075 + 5375ea8 commit f0af4cc

25 files changed

+1052
-118
lines changed

.github/stale.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Configuration for probot-stale - https://github.com/probot/stale
2+
3+
limitPerRun: 30
4+
5+
pulls:
6+
daysUntilStale: 14
7+
daysUntilClose: false
8+
exemptProjects: true
9+
exemptMilestones: true
10+
staleLabel: abandoned
11+
exemptLabels:
12+
- needs review
13+
- on hold
14+
- waiting for CLA pass
15+
16+
markComment: >
17+
Labeling this pull request (PR) as abandoned since it has gone 14 days or more
18+
since the last update. An abandoned PR can be continued by another contributor.
19+
The abandoned label will be removed if work on this PR is taken up again.
20+
21+
issues:
22+
daysUntilStale: 30
23+
daysUntilClose: 40
24+
exemptProjects: true
25+
exemptMilestones: true
26+
staleLabel: stale
27+
exemptLabels:
28+
- bug
29+
- enhancement
30+
- tests
31+
- documentation
32+
- resource proposal
33+
- on hold
34+
35+
markComment: >
36+
This issue has been automatically marked as stale because
37+
it has not had activity from the community in the last 30 days. It will be
38+
closed if no further activity occurs within 10 days. If the issue is labelled
39+
with any of the work labels (e.g bug, enhancement, documentation, or tests)
40+
then the issue will not auto-close.
41+
42+
closeComment: >
43+
This issue has been automatically closed because it is has not had activity
44+
from the community in the last 40 days.

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22

33
## Unreleased
44

5+
## 5.2.0.0
6+
7+
- PowershellExecutionPolicy:
8+
- Updated to meet HQRM guidelines.
9+
- Migrated the xPowershellExecutionPolicy from [xPowershellExecutionPolicy](https://github.com/PowerShell/xPowerShellExecutionPolicy)
10+
and renamed to PowershellExecutionPolicy.
11+
- Moved strings to localization file.
12+
- Changed the scope from Global to Script in MSFT_ScheduledTask.Integration.Tests.ps1
13+
- Changed the scope from Global to Script ComputerManagementDsc.Common.Tests.ps1
14+
- ScheduledTask:
15+
- Added support for event based triggers, implemented using the ScheduleType OnEvent
16+
fixes [Issue #167](https://github.com/PowerShell/ComputerManagementDsc/issues/167)
17+
518
## 5.1.0.0
619

720
- TimeZone:
@@ -11,6 +24,7 @@
1124
ComputerManagementDsc.Common module to match what TimeZone requires.
1225
It was not exported in ComputerManagementDsc.ResourceHelper and not
1326
used.
27+
- Add `server` parameter to `Computer` resource - fixes [Issue #161](https://github.com/PowerShell/ComputerManagementDsc/issues/161)
1428

1529
## 5.0.0.0
1630

Modules/ComputerManagementDsc/ComputerManagementDsc.psd1

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@{
22
# Version number of this module.
3-
moduleVersion = '5.1.0.0'
3+
moduleVersion = '5.2.0.0'
44

55
# ID used to uniquely identify this module
66
GUID = 'B5004952-489E-43EA-999C-F16A25355B89'
@@ -49,13 +49,16 @@ PrivateData = @{
4949
# IconUri = ''
5050

5151
# ReleaseNotes of this module
52-
ReleaseNotes = '- TimeZone:
53-
- Migrated xTimeZone resource from [xTimeZone](https://github.com/PowerShell/xTimeZone)
54-
and renamed to TimeZone - fixes [Issue 157](https://github.com/PowerShell/ComputerManagementDsc/issues/157).
55-
- Moved Test-Command from ComputerManagementDsc.ResourceHelper to
56-
ComputerManagementDsc.Common module to match what TimeZone requires.
57-
It was not exported in ComputerManagementDsc.ResourceHelper and not
58-
used.
52+
ReleaseNotes = '- PowershellExecutionPolicy:
53+
- Updated to meet HQRM guidelines.
54+
- Migrated the xPowershellExecutionPolicy from [xPowershellExecutionPolicy](https://github.com/PowerShell/xPowerShellExecutionPolicy)
55+
and renamed to PowershellExecutionPolicy.
56+
- Moved strings to localization file.
57+
- Changed the scope from Global to Script in MSFT_ScheduledTask.Integration.Tests.ps1
58+
- Changed the scope from Global to Script ComputerManagementDsc.Common.Tests.ps1
59+
- ScheduledTask:
60+
- Added support for event based triggers, implemented using the ScheduleType OnEvent
61+
fixes [Issue 167](https://github.com/PowerShell/ComputerManagementDsc/issues/167)
5962
6063
'
6164

@@ -65,3 +68,4 @@ PrivateData = @{
6568
}
6669

6770

71+

Modules/ComputerManagementDsc/DSCResources/MSFT_Computer/MSFT_Computer.psm1

Lines changed: 65 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ $script:localizedData = Get-LocalizedData `
4545
4646
.PARAMETER Description
4747
The value assigned here will be set as the local computer description.
48+
49+
.PARAMETER Server
50+
The Active Directory Domain Controller to use to join the domain.
4851
#>
4952
function Get-TargetResource
5053
{
@@ -80,7 +83,11 @@ function Get-TargetResource
8083

8184
[Parameter()]
8285
[System.String]
83-
$Description
86+
$Description,
87+
88+
[Parameter()]
89+
[System.String]
90+
$Server
8491
)
8592

8693
Write-Verbose -Message ($script:localizedData.GettingComputerStateMessage -f $Name)
@@ -112,6 +119,7 @@ function Get-TargetResource
112119
UnjoinCredential = [ciminstance] $convertToCimUnjoinCredential
113120
WorkGroupName = (Get-CimInstance -Class 'Win32_ComputerSystem').Workgroup
114121
Description = (Get-CimInstance -Class 'Win32_OperatingSystem').Description
122+
Server = Get-LogonServer
115123
}
116124

117125
return $returnValue
@@ -142,6 +150,9 @@ function Get-TargetResource
142150
143151
.PARAMETER Description
144152
The value assigned here will be set as the local computer description.
153+
154+
.PARAMETER Server
155+
The Active Directory Domain Controller to use to join the domain.
145156
#>
146157
function Set-TargetResource
147158
{
@@ -176,7 +187,11 @@ function Set-TargetResource
176187

177188
[Parameter()]
178189
[System.String]
179-
$Description
190+
$Description,
191+
192+
[Parameter()]
193+
[System.String]
194+
$Server
180195
)
181196

182197
Write-Verbose -Message ($script:localizedData.SettingComputerStateMessage -f $Name)
@@ -208,71 +223,42 @@ function Set-TargetResource
208223
}
209224
else
210225
{
226+
$addComputerParameters = @{
227+
DomainName = $DomainName
228+
Credential = $Credential
229+
Force = $true
230+
}
231+
$rename = $false
211232
if ($Name -ne $env:COMPUTERNAME)
212233
{
213-
# Rename the computer, and join it to the domain.
214-
if ($UnjoinCredential)
215-
{
216-
Add-Computer `
217-
-DomainName $DomainName `
218-
-Credential $Credential `
219-
-NewName $Name `
220-
-UnjoinDomainCredential $UnjoinCredential `
221-
-Force
222-
}
223-
else
224-
{
225-
if ($JoinOU)
226-
{
227-
Add-Computer `
228-
-DomainName $DomainName `
229-
-Credential $Credential `
230-
-NewName $Name `
231-
-OUPath $JoinOU `
232-
-Force
233-
}
234-
else
235-
{
236-
Add-Computer `
237-
-DomainName $DomainName `
238-
-Credential $Credential `
239-
-NewName $Name `
240-
-Force
241-
}
242-
}
234+
$addComputerParameters.Add("NewName", $Name)
235+
$rename = $true
236+
}
237+
238+
if ($UnjoinCredential)
239+
{
240+
$addComputerParameters.Add("UnjoinDomainCredential", $UnjoinCredential)
241+
}
242+
243+
if ($JoinOU)
244+
{
245+
$addComputerParameters.Add("OUPath", $JoinOU)
246+
}
247+
248+
if ($Server)
249+
{
250+
$addComputerParameters.Add("Server", $Server)
251+
}
252+
253+
# Rename the computer, and join it to the domain.
254+
Add-Computer @addComputerParameters
243255

256+
if ($rename)
257+
{
244258
Write-Verbose -Message ($script:localizedData.RenamedComputerAndJoinedDomainMessage -f $Name,$DomainName)
245259
}
246260
else
247261
{
248-
# Same computer name, and join it to the domain.
249-
if ($UnjoinCredential)
250-
{
251-
Add-Computer `
252-
-DomainName $DomainName `
253-
-Credential $Credential `
254-
-UnjoinDomainCredential $UnjoinCredential `
255-
-Force
256-
}
257-
else
258-
{
259-
if ($JoinOU)
260-
{
261-
Add-Computer `
262-
-DomainName $DomainName `
263-
-Credential $Credential `
264-
-OUPath $JoinOU `
265-
-Force
266-
}
267-
else
268-
{
269-
Add-Computer `
270-
-DomainName $DomainName `
271-
-Credential $Credential `
272-
-Force
273-
}
274-
}
275-
276262
Write-Verbose -Message ($script:localizedData.JoinedDomainMessage -f $DomainName)
277263
}
278264
}
@@ -449,7 +435,11 @@ function Test-TargetResource
449435

450436
[Parameter()]
451437
[System.String]
452-
$Description
438+
$Description,
439+
440+
[Parameter()]
441+
[System.String]
442+
$Server
453443
)
454444

455445
Write-Verbose -Message ($script:localizedData.TestingComputerStateMessage -f $Name)
@@ -621,4 +611,18 @@ function Get-ComputerOU
621611
return $ou
622612
}
623613

614+
<#
615+
.SYNOPSIS
616+
Returns the logon server.
617+
#>
618+
function Get-LogonServer
619+
{
620+
[CmdletBinding()]
621+
[OutputType([System.String])]
622+
param()
623+
624+
$logonserver = $env:LOGONSERVER -replace "\\",""
625+
return $logonserver
626+
}
627+
624628
Export-ModuleMember -Function *-TargetResource

Modules/ComputerManagementDsc/DSCResources/MSFT_Computer/MSFT_Computer.schema.mof

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ class MSFT_Computer : OMI_BaseResource
88
[Write, Description("Credential to be used to leave a domain."), EmbeddedInstance("MSFT_Credential")] String UnjoinCredential;
99
[Write, Description("The name of the workgroup.")] String WorkGroupName;
1010
[Write, Description("The value assigned here will be set as the local computer description.")] String Description;
11+
[Write, Description("The Active Directory Domain Controller to use to join the domain")] String Server;
1112
[Read, Description("A read-only property that specifies the organizational unit that the computer account is currently in.")] String CurrentOU;
1213
};

0 commit comments

Comments
 (0)