<# ======================================================================== CREATE OU ======================================================================== #> New-ADOrganizationalUnit -Name "VEG-HR" -Path "DC=veg,DC=cloud" New-ADOrganizationalUnit -Name "Computers" -Path "OU=VEG-HR,DC=veg,DC=cloud" New-ADOrganizationalUnit -Name "Service Accounts" -Path "OU=VEG-HR,DC=veg,DC=cloud" New-ADOrganizationalUnit -Name "Users" -Path "OU=VEG-HR,DC=veg,DC=cloud" New-ADOrganizationalUnit -Name "VEG-Accounting" -Path "DC=veg,DC=cloud" New-ADOrganizationalUnit -Name "Computers" -Path "OU=VEG-Accounting,DC=veg,DC=cloud" New-ADOrganizationalUnit -Name "Service Accounts" -Path "OU=VEG-Accounting,DC=veg,DC=cloud" New-ADOrganizationalUnit -Name "Users" -Path "OU=VEG-Accounting,DC=veg,DC=cloud" New-ADOrganizationalUnit -Name "VEG-Sales" -Path "DC=veg,DC=cloud" New-ADOrganizationalUnit -Name "Computers" -Path "OU=VEG-Sales,DC=veg,DC=cloud" New-ADOrganizationalUnit -Name "Service Accounts" -Path "OU=VEG-Sales,DC=veg,DC=cloud" New-ADOrganizationalUnit -Name "Users" -Path "OU=VEG-Sales,DC=veg,DC=cloud" New-ADOrganizationalUnit -Name "VEG-IT" -Path "DC=veg,DC=cloud" New-ADOrganizationalUnit -Name "Computers" -Path "OU=VEG-IT,DC=veg,DC=cloud" New-ADOrganizationalUnit -Name "Service Accounts" -Path "OU=VEG-IT,DC=veg,DC=cloud" New-ADOrganizationalUnit -Name "Users" -Path "OU=VEG-IT,DC=veg,DC=cloud" New-ADOrganizationalUnit -Name "VEG-Marketing" -Path "DC=veg,DC=cloud" New-ADOrganizationalUnit -Name "Computers" -Path "OU=VEG-Marketing,DC=veg,DC=cloud" New-ADOrganizationalUnit -Name "Service Accounts" -Path "OU=VEG-Marketing,DC=veg,DC=cloud" New-ADOrganizationalUnit -Name "Users" -Path "OU=VEG-Marketing,DC=veg,DC=cloud" <# ======================================================================== IMPORT USERS (USERS, SERVICE ACCOUNTS, ROBOT ACCOUNTS) ======================================================================== #> $Import = Import-CSV "c:\TEMP\users.csv" -Delimiter "," $OU = "OU=Users,OU=VEG-IT,DC=veg,DC=cloud" $Password = ConvertTo-SecureString "P@ssw0rd" -AsPlainText -Force foreach ($user in $Import) { $DisplayName = $user.Name New-ADUser -DisplayName $DisplayName -Name $user.SamAccountName -GivenName $user.GivenName -Surname $user.Surname -Path $OU -AccountPassword $Password -ChangePasswordAtLogon $True -PasswordNeverExpires $false -Enabled $True -UserPrincipalName $user.UserPrincipalName } <# ======================================================================== CREATE GROUP ======================================================================== #> New-ADGroup -Name "VEG-IT-Admins" -SamAccountName "VEG-IT-Admins" -GroupCategory Security -GroupScope Global -DisplayName "VEG-IT-Admins" -Path "OU=Users,OU=VEG-IT,DC=veg,DC=cloud" New-ADGroup -Name "VEG-IT-Developers" -SamAccountName "VEG-IT-Developers" -GroupCategory Security -GroupScope Global -DisplayName "VEG-IT-Developers" -Path "OU=Users,OU=VEG-IT,DC=veg,DC=cloud" New-ADGroup -Name "VEG-IT-RemoteUsers" -SamAccountName "VEG-IT-RemoteUsers" -GroupCategory Security -GroupScope Global -DisplayName "VEG-IT-RemoteUsers" -Path "OU=Users,OU=VEG-IT,DC=veg,DC=cloud" New-ADGroup -Name "VEG-IT-ServiceAccounts" -SamAccountName "VEG-IT-ServiceAccounts" -GroupCategory Security -GroupScope Global -DisplayName "VEG-IT-ServiceAccounts" -Path "OU=Service Accounts,OU=VEG-IT,DC=veg,DC=cloud" <# ======================================================================== ASSIGN USERS TO GROUP ======================================================================== #> Add-ADGroupMember -Identity "Domain Admins" -Members tomato Add-ADGroupMember -Identity "VEG-IT-Admins" -Members tomato, poteto, broccoli Add-ADGroupMember -Identity "VEG-IT-Developers" -Members corn, pumpkin, pepper Add-ADGroupMember -Identity "VEG-IT-RemoteUsers" -Members tomato, poteto, broccoli, corn, pumpkin, pepper Add-ADGroupMember -Identity "VEG-IT-ServiceAccounts" -Members eggplant, cellery