Voor mijn lab omgeving wilde ik vlot wat gebruikers aanmaken. Ik richtte me tot chatgpt… “in labspace.local create OU’s under OU labrats. Name the OU’s after the bands thewho, ledzeppelin, queen, aerosmith, metallica,gunsnroses. fill the OU’s with respective bandmember accounts”
Allereerst kreeg ik het antwoord:
To create Organizational Units (OUs) and user accounts under the “labrats” OU in labspace.local, follow these steps using Active Directory:
- Open Active Directory Users and Computers:
- You can find this tool in Server Manager > Tools > Active Directory Users and Computers.
- Create the OUs for the Bands:
- In Active Directory Users and Computers, right-click on the labrats OU and choose New > Organizational Unit.
- Name the OUs after the bands as listed:
thewho
ledzeppelin
queen
aerosmith
metallica
gunsnroses
- Create User Accounts for Each Band’s Members:
- For each OU, right-click the respective band OU (e.g., thewho) and select New > User.
- Create the user accounts for each of the band members. Below is a general list of the band members to create accounts for:
- Roger Daltrey
- Pete Townshend
- John Entwistle (deceased, can be noted as such)
- Keith Moon (deceased, can be noted as such)
- Robert Plant
- Jimmy Page
- John Paul Jones
- John Bonham (deceased, can be noted as such)
- Freddie Mercury (deceased, can be noted as such)
- Brian May
- John Deacon
- Roger Taylor
- Steven Tyler
- Joe Perry
- Tom Hamilton
- Brad Whitford
- Joey Kramer
- James Hetfield
- Lars Ulrich
- Kirk Hammett
- Robert Trujillo
- Axl Rose
- Slash
- Duff McKagan
- Izzy Stradlin
- Steven Adler (former member, can be noted as such)
- Fill in the User Information:
- For each user, provide the necessary details like First Name, Last Name, User logon name, etc.
- Example for Roger Daltrey (The Who):
- First Name: Roger
- Last Name: Daltrey
- User logon name: roger.daltrey
- Repeat the Process:
- Continue creating the user accounts for each of the band members in their respective OUs.
- Assign Passwords:
- Once the user accounts are created, assign appropriate temporary passwords and ensure that users change their passwords upon their first login.
If you need the actual PowerShell script for this task or additional details, let me know!
Dat laatste deed ik dus…
# Define the root OU where all band OUs will be created
$rootOU = "OU=labrats,DC=labspace,DC=local"
# Define the band names and their members
$bands = @{
"thewho" = @("Roger Daltrey", "Pete Townshend", "John Entwistle", "Keith Moon")
"ledzeppelin" = @("Robert Plant", "Jimmy Page", "John Paul Jones", "John Bonham")
"queen" = @("Freddie Mercury", "Brian May", "John Deacon", "Roger Taylor")
"aerosmith" = @("Steven Tyler", "Joe Perry", "Tom Hamilton", "Brad Whitford", "Joey Kramer")
"metallica" = @("James Hetfield", "Lars Ulrich", "Kirk Hammett", "Robert Trujillo")
"gunsnroses" = @("Axl Rose", "Slash", "Duff McKagan", "Izzy Stradlin", "Steven Adler")
}
# Loop through each band and create the OUs and user accounts
foreach ($band in $bands.Keys) {
# Create the OU for the band
$ouName = $band
$ouPath = "OU=$ouName,$rootOU"
New-ADOrganizationalUnit -Name $ouName -Path "OU=labrats,DC=labspace,DC=local"
# Create the user accounts for each band member
foreach ($member in $bands[$band]) {
# Split the member name into first and last names
$nameParts = $member -split " "
$firstName = $nameParts[0]
$lastName = $nameParts[1]
# Generate the username (you could customize this)
$username = "$firstName.$lastName"
# Create the user account
New-ADUser -Name "$firstName $lastName" `
-GivenName $firstName `
-Surname $lastName `
-SamAccountName $username `
-UserPrincipalName "$username@labspace.local" `
-Path $ouPath `
-AccountPassword (ConvertTo-SecureString "P@ssw0rd123" -AsPlainText -Force) `
-Enabled $true `
-ChangePasswordAtLogon $true `
-PassThru
}
}
Write-Host "All OUs and users have been created successfully!"