diff --git a/powershell/Modules/ModPlatformAD/ModPlatformADOU.psm1 b/powershell/Modules/ModPlatformAD/ModPlatformADOU.psm1 index 6e03d1e06..c1e056fae 100644 --- a/powershell/Modules/ModPlatformAD/ModPlatformADOU.psm1 +++ b/powershell/Modules/ModPlatformAD/ModPlatformADOU.psm1 @@ -1,59 +1,19 @@ -# function New-ADOrganizationalUnit { - -# <# -# .SYNOPSIS -# Creates a New-ADOrganizationalUnit - -# .DESCRIPTION -# Using configuration returned from Get-ModPlatformADConfig, this function -# optionally assumes a role to access a secret containing the password of the -# domain join username. EC2 requires permissions to join the given role, -# a SSM parameter containing account IDs, and the aws cli. - -# .PARAMETER Name -# Name of the Organizational Unit to create - -# .PARAMETER Path -# The path of the Organizational Unit to create - -# .PARAMETER Description -# Description of the Organizational Unit to create - -# .PARAMETER ProtectedFromAccidentalDeletion -# Whether the Organizational Unit should be protected from accidental deletion, defaults to false - -# .EXAMPLE -# New-ADOrganizationalUnit -Name "TestOU" -Path "OU=Test,DC=example,DC=com" -Description "Test OU" - -# .OUTPUTS -# OU folder created -# #> - -# [CmdletBinding()] -# param ( -# [Parameter(Mandatory = $true)] -# [string]$Name, - -# [Parameter(Mandatory = $true)] -# [string]$Path, - -# [Parameter(Mandatory = $false)] -# [string]$Description, - -# [Parameter(Mandatory = $false)] -# [bool]$ProtectedFromAccidentalDeletion = $false -# ) - -# $ou = Get-ADOrganizationalUnit -Filter "Name -eq '$Name'" -SearchBase $Path -# if ($ou) { -# Write-Host "Organizational Unit $Name already exists in $Path" -ForegroundColor Yellow -# } else { -# $ou = New-ADOrganizationalUnit -Name $Name -Path $Path -Description $Description -ProtectedFromAccidentalDeletion $ProtectedFromAccidentalDeletion -# Write-Host "Organizational Unit $Name created in $Path" -ForegroundColor Green -# } -# } - function Set-OUsAndApplyGPOs { +<# +.SYNOPSIS + Recursively creates Organizational Units (OUs) and applies Group Policy Objects (GPOs) to the given domain +.DESCRIPTION + Recursively creates Organizational Units (OUs) and applies Group Policy Objects (GPOs) to the given domain +.PARAMETER Ou + The OU to create +.PARAMETER Path + The path of the OU to create +.PARAMETER ProtectedFromAccidentalDeletion + Whether the OU should be protected from accidental deletion, defaults to false + In production environments, it is recommended to set this to true +.OUTPUTS + OU folder created +#> param ( [Parameter(Mandatory=$true)] [psobject]$Ou, @@ -87,5 +47,4 @@ function Set-OUsAndApplyGPOs { } } -# Export-ModuleMember -Function New-ADOrganizationalUnit -Export-ModuleMember -Function Set-OUsAndApplyGPOs +# Export-ModuleMember -Function Set-OUsAndApplyGPOs diff --git a/powershell/Scripts/ModPlatformAD/New-ModPlatformGPO.ps1 b/powershell/Scripts/ModPlatformAD/New-ModPlatformGPO.ps1 index 2d35bbf2f..3b505b510 100644 --- a/powershell/Scripts/ModPlatformAD/New-ModPlatformGPO.ps1 +++ b/powershell/Scripts/ModPlatformAD/New-ModPlatformGPO.ps1 @@ -16,6 +16,7 @@ ./New-ModPlatformGPO.ps1 -DomainNameFQDN "test.loc" -ConfigFilePath "config.yaml" .OUTPUTS + Check Group Policy Management tools on the server to see the GPOs created #> diff --git a/powershell/Scripts/ModPlatformAD/Set-ModPlatformADOUStructure.ps1 b/powershell/Scripts/ModPlatformAD/Set-ModPlatformADOUStructure.ps1 index 74617eefc..2f42a810d 100644 --- a/powershell/Scripts/ModPlatformAD/Set-ModPlatformADOUStructure.ps1 +++ b/powershell/Scripts/ModPlatformAD/Set-ModPlatformADOUStructure.ps1 @@ -1,6 +1,6 @@ <# .SYNOPSIS - Retrieve appropriate AD config for the given Modernisation Platform environment. + Applies the OU and GPO structure to the given domain based on a yaml config file. .DESCRIPTION Either pass in the domain name as a parameter, or derive the AD configuration @@ -10,10 +10,14 @@ .PARAMETER DomainNameFQDN Specify the FQDN of the domain name to join +.PARAMETER ConfigFilePath + Path to the yaml definition of the OU/GPO structure. See ../../Configs/ADConfigDevTest.yaml for example + .EXAMPLE - $ADConfig = Get-ModPlatformADConfig + ./Set-ModPlatformADOUStructure.ps1 -DomainNameFQDN "test.loc" -ConfigFilePath "../../Configs/ADConfigDevTest.yaml" -.OUTPUTS +.NOTES + GPO's referenced in the script have to have been created FIRST before running this, otherwise GPO's will not be applied #>