You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (-not [System.String]::IsNullOrEmpty($Options))
267
+
{
268
+
<#
269
+
See https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/add-computer?view=powershell-5.1#parameters for available options and their description
270
+
#>
271
+
Assert-ResourceProperty@PSBoundParameters
272
+
$addComputerParameters.Add('Options',$Options)
273
+
}
274
+
250
275
# Rename the computer, and join it to the domain.
251
276
try
252
277
{
@@ -422,6 +447,9 @@ function Set-TargetResource
422
447
423
448
.PARAMETERDescription
424
449
The value assigned here will be set as the local computer description.
450
+
451
+
.PARAMETEROptions
452
+
Specifies advanced options for the Add-Computer join operation.
Copy file name to clipboardExpand all lines: tests/Unit/DSC_Computer.Tests.ps1
+57Lines changed: 57 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -683,6 +683,34 @@ try
683
683
Assert-MockCalled-CommandName Add-Computer-Exactly -Times 0-Scope It -ParameterFilter { $WorkGroupName }
684
684
}
685
685
686
+
It 'Changes ComputerName and changes Domain to new Domain with Options passed' {
687
+
Mock -CommandName Get-WMIObject-MockWith {
688
+
[PSCustomObject] @{
689
+
Domain='Contoso.com';
690
+
Workgroup='Contoso.com';
691
+
PartOfDomain=$true
692
+
}
693
+
}
694
+
695
+
Mock -CommandName Get-ComputerDomain-MockWith {
696
+
'contoso.com'
697
+
}
698
+
699
+
Mock -CommandName Add-Computer
700
+
701
+
Set-TargetResource`
702
+
-Name $notComputerName`
703
+
-DomainName 'adventure-works.com'`
704
+
-Credential $credential`
705
+
-UnjoinCredential $credential`
706
+
-Options @('InstallInvoke') `
707
+
-Verbose | Should -BeNullOrEmpty
708
+
709
+
Assert-MockCalled-CommandName Rename-Computer-Exactly -Times 0-Scope It
710
+
Assert-MockCalled-CommandName Add-Computer-Exactly -Times 1-Scope It -ParameterFilter { $DomainName-and$NewName }
711
+
Assert-MockCalled-CommandName Add-Computer-Exactly -Times 0-Scope It -ParameterFilter { $WorkGroupName }
712
+
}
713
+
686
714
It 'Should try a separate rename if ''FailToRenameAfterJoinDomain'' occured during domain join' {
687
715
$message="Computer '' was successfully joined to the new domain '', but renaming it to '' failed with the following error message: The directory service is busy."
0 commit comments