Skip to content

Commit

Permalink
ADSEcurity: minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
przybylskirobert committed Jan 22, 2024
1 parent 989cf9d commit bd1737e
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 26 deletions.
14 changes: 10 additions & 4 deletions Tiering/Scripts/Create-Group.ps1
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<#
.Example
$csv = Read-Host -Prompt "Please provide full path to Groups csv file"
.\Create-Group.ps1 -CSVfile $csv -Verbose
.\Create-Group.ps1 List $csv -Verbose
PS C:\Tools> $csv = Read-Host -Prompt "Please provide full path to Groups csv file"
Please provide full path to Groups csv file: c:\tools\groups.csv
PS C:\Tools> .\Create-Group.ps1 -CSVfile $csv -Verbose
PS C:\Tools> .\Create-Group.ps1 List $csv -Verbose
VERBOSE: Creating new Group 'Tier0ReplicationMaintenance' under 'OU=Groups,OU=Tier0,OU=Admin,DC=azureblog,DC=pl'
VERBOSE: Creating new Group 'Tier1ServerMaintenance' under 'OU=Groups,OU=Tier1,OU=Admin,DC=azureblog,DC=pl'
VERBOSE: Creating new Group 'ServiceDeskOperators' under 'OU=Groups,OU=Tier2,OU=Admin,DC=azureblog,DC=pl'
Expand All @@ -15,10 +15,16 @@

[CmdletBinding()]
param(
[parameter(Mandatory = $true)][string] $CSVfile
[parameter(Mandatory = $true)][PSOBject] $List
)
$dNC = (Get-ADRootDSE).defaultNamingContext
$groups = Import-Csv $CSVfile
if ($List -like "*csv*") {
if (Test-Path -Path $List){
Write-Host "Working with CSV File '$List'" -ForegroundColor Green
$groups = Import-CSV -Path $List
}
}

foreach ($group in $groups) {
$groupName = $group.Name
$groupOUPrefix = $group.OU
Expand Down
8 changes: 5 additions & 3 deletions Tiering/Scripts/Create-OU.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ param(
[parameter(Mandatory = $true)][PSObject] $OUs
)
$dNC = (Get-ADRootDSE).defaultNamingContext
if (test-Path -Path $OUs) {
Write-Host "Working with CSV File '$OUs'" -ForegroundColor Green
$OUs = Import-CSV -Path $OUs
if ($OUs -like "*csv*") {
if (Test-Path -Path $OUs){
Write-Host "Working with CSV File '$OUs'" -ForegroundColor Green
$OUs = Import-CSV -Path $OUs
}
}

$OUs | ForEach-Object {
Expand Down
8 changes: 5 additions & 3 deletions Tiering/Scripts/Set-OUComputerPermissions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ $domain = Get-ADDomain
$guidmap = @{ }
Get-ADObject -SearchBase ($rootdse.SchemaNamingContext) -LDAPFilter "(schemaidguid=*)" -Properties lDAPDisplayName, schemaIDGUID | ForEach-Object { $guidmap[$_.lDAPDisplayName] = [System.GUID]$_.schemaIDGUID }

if (test-Path -Path $List) {
Write-Host "Working with CSV File '$List'" -ForegroundColor Green
$List = Import-CSV -Path $List
if ($List -like "*csv*") {
if (Test-Path -Path $List){
Write-Host "Working with CSV File '$List'" -ForegroundColor Green
$List = Import-CSV -Path $List
}
}

$List | ForEach-Object {
Expand Down
8 changes: 5 additions & 3 deletions Tiering/Scripts/Set-OUGPOPermissions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ Get-ADObject -SearchBase ($rootdse.SchemaNamingContext) -LDAPFilter "(schemaidgu
$extendedrightsmap = @{ }
Get-ADObject -SearchBase ($rootdse.ConfigurationNamingContext) -LDAPFilter "(&(objectclass=controlAccessRight)(rightsguid=*))" -Properties displayName, rightsGuid | ForEach-Object { $extendedrightsmap[$_.displayName] = [System.GUID]$_.rightsGuid }

if (test-Path -Path $List) {
Write-Host "Working with CSV File '$List'" -ForegroundColor Green
$List = Import-CSV -Path $List
if ($List -like "*csv*") {
if (Test-Path -Path $List){
Write-Host "Working with CSV File '$List'" -ForegroundColor Green
$List = Import-CSV -Path $List
}
}

$List | ForEach-Object {
Expand Down
8 changes: 5 additions & 3 deletions Tiering/Scripts/Set-OUGroupPermissions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ Get-ADObject -SearchBase ($rootdse.SchemaNamingContext) -LDAPFilter "(schemaidgu
$extendedrightsmap = @{ }
Get-ADObject -SearchBase ($rootdse.ConfigurationNamingContext) -LDAPFilter "(&(objectclass=controlAccessRight)(rightsguid=*))" -Properties displayName, rightsGuid | ForEach-Object { $extendedrightsmap[$_.displayName] = [System.GUID]$_.rightsGuid }

if (test-Path -Path $List) {
Write-Host "Working with CSV File '$List'" -ForegroundColor Green
$List = Import-CSV -Path $List
if ($List -like "*csv*") {
if (Test-Path -Path $List){
Write-Host "Working with CSV File '$List'" -ForegroundColor Green
$List = Import-CSV -Path $List
}
}

$List | ForEach-Object {
Expand Down
8 changes: 5 additions & 3 deletions Tiering/Scripts/Set-OUReplicationPermissions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ $forestDnsZonesDN = "DC=ForestDnsZones," + $rootdse.RootDomainNamingContext
$sitesDN = "CN=Sites," + $configCN
$config = @($configCN, $schemaNC, $forestDnsZonesDN, $sitesDN)

if (test-Path -Path $List) {
Write-Host "Working with CSV File '$List'" -ForegroundColor Green
$List = Import-CSV -Path $List
if ($List -like "*csv*") {
if (Test-Path -Path $List){
Write-Host "Working with CSV File '$List'" -ForegroundColor Green
$List = Import-CSV -Path $List
}
}

$List | ForEach-Object {
Expand Down
8 changes: 5 additions & 3 deletions Tiering/Scripts/Set-OUUserPermissions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ Get-ADObject -SearchBase ($rootdse.SchemaNamingContext) -LDAPFilter "(schemaidgu
$extendedrightsmap = @{ }
Get-ADObject -SearchBase ($rootdse.ConfigurationNamingContext) -LDAPFilter "(&(objectclass=controlAccessRight)(rightsguid=*))" -Properties displayName, rightsGuid | ForEach-Object { $extendedrightsmap[$_.displayName] = [System.GUID]$_.rightsGuid }

if (test-Path -Path $List) {
Write-Host "Working with CSV File '$List'" -ForegroundColor Green
$List = Import-CSV -Path $List
if ($List -like "*csv*") {
if (Test-Path -Path $List){
Write-Host "Working with CSV File '$List'" -ForegroundColor Green
$List = Import-CSV -Path $List
}
}

$List | ForEach-Object {
Expand Down
8 changes: 5 additions & 3 deletions Tiering/Scripts/Set-OUWorkstationPermissions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ $domain = Get-ADDomain
$guidmap = @{ }
Get-ADObject -SearchBase ($rootdse.SchemaNamingContext) -LDAPFilter "(schemaidguid=*)" -Properties lDAPDisplayName, schemaIDGUID | ForEach-Object { $guidmap[$_.lDAPDisplayName] = [System.GUID]$_.schemaIDGUID }

if (test-Path -Path $List) {
Write-Host "Working with CSV File '$List'" -ForegroundColor Green
$List = Import-CSV -Path $List
if ($List -like "*csv*") {
if (Test-Path -Path $List){
Write-Host "Working with CSV File '$List'" -ForegroundColor Green
$List = Import-CSV -Path $List
}
}

$List | ForEach-Object {
Expand Down
2 changes: 1 addition & 1 deletion Tiering/Tiering_steps.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ $OUs = @(
#endRegion

#region create Tiering OUs v2
$domainOUSCsv = Import-Csv -Path "$ScriptsLocation\DomainOUs.csv"
$domainOUSCsv = "$ScriptsLocation\DomainOUs.csv"
.$ScriptsLocation\Scripts\Create-OU.ps1 -OUs $domainOUSCsv
#endregion

Expand Down

0 comments on commit bd1737e

Please sign in to comment.