Table of Contents

Learn Active Directory Management in a Month of Lunches

A book by Richard Siddaway

PART 1 MANAGING ACTIVE DIRECTORY DATA

1 Before you begin

1.1 AD core deliverables

1.1.1 Authentication
1.1.2 Authorization
1.1.3 AD definitions

1.2 Is this book for you?

…

1.3 How to use this book

…

1.4 Creating your lab environment

…

1.5 Being immediately effective

…

2 Creating user accounts

Computer accounts are a specialized form of user account. In most organizations they’re put into separate organizational units (OUs) to make the Group Policy Object (GPO) application simpler.

IDEA: - make user groups to make administration of GPOs for our OUs simpler.

2.1 Creating new user accounts

2.1.1 Creating a new user with ADAC
2.1.2 Creating a new user with ADUC
2.1.3 Creating a new user with PowerShell

The following code can be used to create a new user:

$secpass = Read-Host "Password" -AsSecureString
New-ADUser -Name "GREEN Dave" -SamAccountName dgreen
➥ -UserPrincipalName "dgreen@manticore.org" -AccountPassword $secpass
➥ -Path "cn=Users,dc=Manticore,dc=org" -Enabled:$true

2.2 User creation from a template

One way to reduce the amount of work you need to perform and reduce the chance of an error occurring is to use a template. This is a fully configured account that’s copied to form a new account.

$secpass = Read-Host "Password" -AsSecureString
$user = Get-ADUser -Identity jgreen -Properties memberof, office
New-ADUser -Name "GREEN Bill" -SamAccountName bgreen
➥ -UserPrincipalName "bgreen@manticore.org"
➥ -AccountPassword $secpass -Path "cn=Users,dc=Manticore,dc=org"
➥ -Enabled:$true -Instance $user

2.3 User creation in bulk

$secpass = Read-Host "Password" -AsSecureString
Import-Csv names.csv |
foreach {
$name = "$($_.LastName) $($_.FirstName)"
New-ADUser -GivenName $($_.FirstName) -Surname $($_.LastName) `
-Name $name -SamAccountName $($_.SamAccountName) `
-UserPrincipalName "$($_.SamAccountName)@manticore.org" `
-AccountPassword $secpass -Path "cn=Users,dc=Manticore,dc=org" `
-Enabled:$true
}

2.4 Creating managed service accounts

… (not really important for me at this time)

2.5 Lab

… (not really important for me at this time)

2.6 Ideas for on your own

3 Managing user accounts

User account management can be summed up as CRUD (create, read, update, delete).

3.1 Modifying user account properties

3.1.1 Using GUI tools to modify user accounts

…

3.1.2 Using PowerShell to modify user accounts
Set-ADUser -Identity "CN=GREEN Bill,CN=Users,DC=Manticore,DC=org" `
-OfficePhone "01234 567895"
Set-ADUser -Identity "CN=GREEN Bill,CN=Users,DC=Manticore,DC=org" -Replace @{otherTelephone="01234 567896","01234 567897"}
3.1.3 Copying attributes from another account

Copying attributes with GUI tools is a bit long-winded, and you’ll soon get bored if you have to do this for a number of users.

A little bit of PowerShell can make your life much easier:

$source = Get-ADUser -Identity bgreen -Properties OfficePhone, otherTelephone
Set-ADUser -Identity "CN=GREEN Dave,CN=Users,DC=Manticore,DC=org"
➥ -OfficePhone $($source.OfficePhone)
➥ -Replace @{otherTelephone = $($source.otherTelephone)}

3.2 Enabling or disabling user accounts

Disable with PowerShell:

Disable-ADAccount -Identity dgreen

Enable with PowerShell:

Enable-ADAccount -Identity dgreen

3.3 Deleting user accounts

Remove-ADUser -Identity dgreen -Confirm:$false

Leave off the -Confirm:$false if you want a message to force you to confirm the action. Not a bad idea with deletes!

3.4 Lab

…

3.5 Ideas for on your own

…

4 Managing groups

4.1 Group types

…

4.2 Group lifecycle

4.2.1 Creating groups
New-ADGroup -Name PStest -Path "CN=Users,DC=Manticore,DC=org"
➥ -GroupCategory Security -GroupScope Global
➥ -Description "Test group for AD Lunches"
4.2.2 Changing group scope
Set-ADGroup -Identity ADL-group1 -GroupScope Universal
Set-ADGroup -Identity ADL-group3 -GroupScope Universal
Set-ADGroup -Identity ADL-group3 -GroupScope DomainLocal
4.2.3 Deleting a group
Remove-ADGroup -Identity ADL-Test3 -Confirm:$false

4.3 Managing group membership

4.3.1 Using GUI tools to manage group membership
4.3.2 Using PowerShell to manage group membership
Get-ADGroupMember -Identity ADL-group1 | select Name, DistinguishedName
 
Add-ADGroupMember -Identity ADL-group1 -Members "CN=GREEN Bill,CN=Users,DC=Manticore,DC=org"
 
#  Remember, you can search for the user to add to the group:
Add-ADGroupMember -Identity ADL-group1 -Members (Get-ADUser -LDAPFilter "(Name=Green Bill)")
 
Remove-ADGroupMember -Identity ADL-group1 -Members bgreen -Confirm:$false

4.4 Lab

…

4.4.1 Complete the TRY IT NOW sections
4.4.2 Create six new groups
4.4.3 Change group scope
4.4.4 Add group members
4.4.5 Remove a user from group
4.4.6 Nest groups
4.4.7 Delete user account
4.4.8 Add computer account to group

4.5 Ideas for on your own

5 Troubleshooting users and groups

5.1 Troubleshooting first steps

5.1.1 Step 1: Is the account disabled?

the user.

# This code will display a list of disabled accounts.
 
Search-ADAccount -AccountDisabled | select Name, samAccountName
 
# If your user is in the list, enable the account like this:
 
Get-ADUser -Identity dgreen | Enable-ADAccount
5.1.2 Step 2: Check account status
5.1.3 Step 3: Has the account expired?
Search-ADAccount -AccountExpired | Format-Table Name, SamAccountName, DistinguishedName, AccountExpirationDate -AutoSize
Get-ADUser -Identity dgreen | Set-ADAccountExpiration -DateTime (Get-Date).AddDays(30)
 
# Alternatively, you could set a specific date using code like this:
 
Get-ADUser -Identity dgreen | Set-ADAccountExpiration -DateTime ([datetime]'11/25/2013')
 
# WARNING: If you use this technique, the date must be presented as month/day/year. 
Get-ADUser -Identity dgreen | Clear-ADAccountExpiration

5.2 Password expiry

Search-ADAccount -PasswordExpired

5.3 Password reset

$password = Read-Host -Prompt "Password" -AsSecureString
$id = "dgreen"
Set-ADAccountPassword -Identity $id -NewPassword $password -Reset
Set-ADUser -Identity $id -ChangePasswordAtLogon:$true

5.4 Unlocking a user account

5.5 Group membership

$target = Get-ADUser -Identity mgreen -Properties memberof
foreach ($member in $target.memberof){
  Remove-ADGroupMember -Identity $member -Members $target -Confirm:$false
}
 
$source = Get-ADUser -Identity dgreen -Properties memberof
foreach ($member in $source.memberof){
  Add-ADGroupMember -Identity $member -Members $target -Confirm:$false
}

5.6 Lab

5.6.1 Complete any TRY IT NOW sections

…

5.6.2 Account expiry

…

5.6.3 Account lockout

…

5.6.4 Disable an account

…

5.7 Ideas for on your own

6 Managing computer accounts

6.1 Creating an AD computer account

6.1.1 Creating a computer account using ADAC
6.1.2 Creating a computer account using ADUC
6.1.3 Creating a computer account using PowerShell
New-ADComputer -Enabled $true -Name ADLComp3 `
-Path "CN=Computers,DC=Manticore,DC=org" `
-SamAccountName ADLCOMP3

6.2 Joining a computer to the domain

6.2.1 Using GUI tools to join a machine to the domain
6.2.2 Using PowerShell to join a machine to the domain
$cred = Get-Credential
Add-Computer -Credential $cred -DomainName Manticore `
-OUPath "OU=Security Servers,OU=Servers,DC=Manticore,DC=org" -Force
Restart-Computer

6.3 Managing the secure channel

if (-not(Test-ComputerSecureChannel)){
  Test-ComputerSecureChannel -Repair –Verbose
}

6.4 Deleting a computer account

Search-ADAccount -AccountInactive -ComputersOnly | Format-Table Name, DistinguishedName, LastLogonDate, ObjectClass -Autosize
Search-ADAccount -AccountInactive -ComputersOnly -TimeSpan "90:00:00"|
where ObjectClass -eq "Computer" |
Format-Table Name, DistinguishedName, LastLogonDate, ObjectClass -Autosize
Import-Csv -Path C:\Scripts\ADLunches\computersTodelete.txt |
foreach {
Remove-ADComputer -Identity $_.Name -Confirm:$false
}

6.5 Lab

6.5.1 Create computer accounts

…

6.5.2 Create computer accounts in bulk

…

6.5.3 Searching for computer accounts

…

6.5.4 Managing the secure channel

…

6.5.5 Deleting computer accounts

…

6.6 Ideas for on your own

7 Managing organizational units

7.1 OU concepts

7.2 Creating an OU with the GUI tools

7.2.1. Creating an OU with ADAC
7.2.2 Creating an OU with ADUC

7.3 Creating an OU with PowerShell

7.4 Protecting OUs from accidental deletion

7.5 Managing OUs

Renaming an OU 84 ■ Adding a description to the OU 84 Changing the Managed By setting 85 ■ Deleting an OU 86 xii CONTENTS

7.6 Moving objects between OUs

7.7 Lab

Creating OUs 88 ■ Renaming OUs 88 ■ Setting descriptions and Managed By 89 ■ Moving objects between OUs 89 ■ Deleting an OU 90

7.8 Ideas for on your own

PART 2 MANAGING GROUP POLICY

8 Creating Group Policies

9 Managing Group Policies

10 Fine-grained password policies

PART 3 MANAGING THE ACTIVE DIRECTORY SERVICE

11 Creating domain controllers

12 Managing domain controllers

13 Protecting AD data

14 Security: Default groups and delegation

15 Managing DNS

16 Managing sites and subnets

17 AD replication

18 Managing AD trusts

PART 4 MAINTENANCE AND TROUBLESHOOTING

19 Troubleshooting your AD

20 Maintaining and monitoring Active Directory

21 Future work and final exam

22 Into the cloud

MY NOTES