Skip to content

Commit

Permalink
ADComputer: Add example to create cluster computer account (#461)
Browse files Browse the repository at this point in the history
- Changes to ActiveDirectoryDsc
  - Fix examples that had duplicate guid that would have prevented them
    to be published.
- Changes to ADComputer
  - Add example showing how to create cluster computer account (issue #401).
  • Loading branch information
johlju authored Aug 3, 2019
1 parent 2e42a67 commit 51a74bc
Show file tree
Hide file tree
Showing 12 changed files with 134 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
- Updated all the examples files to be prefixed with the resource
name so they are more easily discovered in PowerShell Gallery and
Azure Automation ([issue #416](https://github.com/PowerShell/ActiveDirectoryDsc/issues/416)).
- Fix examples that had duplicate guid that would have prevented them
to be published.
- Changes to ADManagedServiceAccount
- Added a requirement to README stating "Group Managed Service Accounts
need at least one Windows Server 2012 Domain Controller"
Expand All @@ -68,6 +70,7 @@
any credential with enough permission to perform the task ([issue #269](https://github.com/PowerShell/ActiveDirectoryDsc/issues/269)).
- Fixed the GUID in Example 3-AddComputerAccountSpecificPath_Config
([issue #410](https://github.com/PowerShell/ActiveDirectoryDsc/issues/410)).
- Add example showing how to create cluster computer account ([issue #401](https://github.com/PowerShell/ActiveDirectoryDsc/issues/401)).
- Changes to ADOrganizationalUnit
- Catch exception when the path property specifies a non-existing path
([issue #408](https://github.com/PowerShell/ActiveDirectoryDsc/issues/408)).
Expand Down
47 changes: 47 additions & 0 deletions DSCResources/MSFT_ADComputer/en-US/about_ADComputer.help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,51 @@ Configuration ADComputer_AddComputerAccountAndCreateODJRequest_Config
}
}

.EXAMPLE 5

This configuration will create a computer account disabled, configure
a cluster using the disabled computer account, and enforcing the
computer account to be enabled.

Configuration ADComputer_CreateClusterComputerAccount_Config
{
param
(
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[System.Management.Automation.PSCredential]
$Credential
)

Import-DscResource -ModuleName ActiveDirectoryDsc
Import-DscResource -ModuleName xFailoverCluster

node localhost
{
ADComputer 'ClusterAccount'
{
ComputerName = 'CLU_CNO01'
EnabledOnCreation = $false
}

xCluster 'CreateCluster'
{
Name = 'CLU_CNO01'
StaticIPAddress = '192.168.100.20/24'
DomainAdministratorCredential = $Credential

DependsOn = '[ADComputer]ClusterAccount'
}

ADObjectEnabledState 'EnforceEnabledPropertyToEnabled'
{
Identity = 'CLU_CNO01'
ObjectClass = 'Computer'
Enabled = $true

DependsOn = '[xCluster]CreateCluster'
}
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@
WaitForADDomain

.DESCRIPTION
The WaitForADDomain resource is used to wait for Active Directory to become available.
The WaitForADDomain resource is used to wait for Active Directory domain
controller to become available in the domain, or available in
a specific site in the domain.

>Running the resource as *NT AUTHORITY\SYSTEM*, only work when
>evaluating the domain on the current node, for example on a
>node that should be a domain controller (which might require a
>restart of the node once the node becomes a domain controller).
>In all other scenarios use either the built-in parameter
>`PsDscRunAsCredential`, or the parameter `Credential`.

## Requirements

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<#PSScriptInfo
.VERSION 1.0.0
.GUID 331c7f40-112d-468c-9bd0-8f1b073bee44
.AUTHOR Microsoft Corporation
.COMPANYNAME Microsoft Corporation
.COPYRIGHT (c) Microsoft Corporation. All rights reserved.
.TAGS DSCConfiguration
.LICENSEURI https://github.com/PowerShell/ActiveDirectoryDsc/blob/master/LICENSE
.PROJECTURI https://github.com/PowerShell/ActiveDirectoryDsc
.ICONURI
.EXTERNALMODULEDEPENDENCIES
.REQUIREDSCRIPTS
.EXTERNALSCRIPTDEPENDENCIES
.RELEASENOTES First version.
.PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core
#>

#Requires -module ActiveDirectoryDsc
#Requires -module xFailoverCluster

<#
.DESCRIPTION
This configuration will create a computer account disabled, configure
a cluster using the disabled computer account, and enforcing the
computer account to be enabled.
#>
Configuration ADComputer_CreateClusterComputerAccount_Config
{
param
(
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[System.Management.Automation.PSCredential]
$Credential
)

Import-DscResource -ModuleName ActiveDirectoryDsc
Import-DscResource -ModuleName xFailoverCluster

node localhost
{
ADComputer 'ClusterAccount'
{
ComputerName = 'CLU_CNO01'
EnabledOnCreation = $false
}

xCluster 'CreateCluster'
{
Name = 'CLU_CNO01'
StaticIPAddress = '192.168.100.20/24'
DomainAdministratorCredential = $Credential

DependsOn = '[ADComputer]ClusterAccount'
}

ADObjectEnabledState 'EnforceEnabledPropertyToEnabled'
{
Identity = 'CLU_CNO01'
ObjectClass = 'Computer'
Enabled = $true

DependsOn = '[xCluster]CreateCluster'
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<#PSScriptInfo
.VERSION 1.0.0
.GUID b4d414dc-e230-4055-bdc3-fae268493881
.GUID d2dfbf17-b113-42f7-9abe-f6c6dc5ea086
.AUTHOR Microsoft Corporation
.COMPANYNAME Microsoft Corporation
.COPYRIGHT (c) Microsoft Corporation. All rights reserved.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<#PSScriptInfo
.VERSION 1.0.0
.GUID b4d414dc-e230-4055-bdc3-fae268493881
.GUID 1da557bb-07a1-4461-8f64-df0d62b30305
.AUTHOR Microsoft Corporation
.COMPANYNAME Microsoft Corporation
.COPYRIGHT (c) Microsoft Corporation. All rights reserved.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<#PSScriptInfo
.VERSION 1.0
.GUID b293f599-2660-424d-8200-61d399e44257
.GUID 3bf5100b-238e-435a-8a98-67d756c5cdeb
.AUTHOR Microsoft Corporation
.COMPANYNAME Microsoft Corporation
.COPYRIGHT (c) Microsoft Corporation. All rights reserved.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<#PSScriptInfo
.VERSION 1.0
.GUID 5f105122-a318-46f4-a7e9-7dc745c57878
.GUID ef167bdf-7f25-4d28-8ef3-68918eb2702c
.AUTHOR Microsoft Corporation
.COMPANYNAME Microsoft Corporation
.COPYRIGHT (c) Microsoft Corporation. All rights reserved.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<#PSScriptInfo
.VERSION 1.0
.GUID 5f105122-a318-46f4-a7e9-7dc745c57878
.GUID d0713e4e-274b-4510-949e-39bce2ef2158
.AUTHOR Microsoft Corporation
.COMPANYNAME Microsoft Corporation
.COPYRIGHT (c) Microsoft Corporation. All rights reserved.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<#PSScriptInfo
.VERSION 1.0
.GUID 5f105122-a318-46f4-a7e9-7dc745c57878
.GUID 20e1a154-1197-44e3-9c81-d1b9cc67defd
.AUTHOR Microsoft Corporation
.COMPANYNAME Microsoft Corporation
.COPYRIGHT (c) Microsoft Corporation. All rights reserved.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<#PSScriptInfo
.VERSION 1.0
.GUID 5f105122-a318-46f4-a7e9-7dc745c57878
.GUID 2ada2ead-8736-4d5e-9587-e14bacc28761
.AUTHOR Microsoft Corporation
.COMPANYNAME Microsoft Corporation
.COPYRIGHT (c) Microsoft Corporation. All rights reserved.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<#PSScriptInfo
.VERSION 1.0
.GUID 5f105122-a318-46f4-a7e9-7dc745c57878
.GUID 0d9d34c3-c750-45f8-8611-74087e958fe1
.AUTHOR Microsoft Corporation
.COMPANYNAME Microsoft Corporation
.COPYRIGHT (c) Microsoft Corporation. All rights reserved.
Expand Down

0 comments on commit 51a74bc

Please sign in to comment.