Upload files to "windows-ad/populate_ad"
This commit is contained in:
parent
7ca369aa9f
commit
66c942f679
|
@ -0,0 +1,24 @@
|
||||||
|
# website: activedirectorypro.com
|
||||||
|
|
||||||
|
Import-Module ActiveDirectory
|
||||||
|
|
||||||
|
#Import CSV
|
||||||
|
$groups = Import-Csv c:\it\groups.csv
|
||||||
|
|
||||||
|
|
||||||
|
# Loop through the CSV
|
||||||
|
foreach ($group in $groups) {
|
||||||
|
|
||||||
|
$groupProps = @{
|
||||||
|
|
||||||
|
Name = $group.name
|
||||||
|
Path = $group.path
|
||||||
|
GroupScope = $group.scope
|
||||||
|
GroupCategory = $group.category
|
||||||
|
Description = $group.description
|
||||||
|
|
||||||
|
}#end groupProps
|
||||||
|
|
||||||
|
New-ADGroup @groupProps
|
||||||
|
|
||||||
|
} #end foreach loop
|
|
@ -0,0 +1,24 @@
|
||||||
|
# This script is used for creating bulk OUs from a CSV file
|
||||||
|
# Update the CSV with the OU name and path
|
||||||
|
# website: activedirectorypro.com
|
||||||
|
|
||||||
|
# Import active directory module for running AD cmdlets
|
||||||
|
Import-Module activedirectory
|
||||||
|
|
||||||
|
#Store the data from ADUsers.csv in the $ADUsers variable. CSV template needs the following headers-> name, path
|
||||||
|
$ADOU = Import-csv C:\it\ous.csv
|
||||||
|
|
||||||
|
#Loop through each row containing user details in the CSV file
|
||||||
|
foreach ($ou in $ADou)
|
||||||
|
{
|
||||||
|
#Read data from each field in each row and assign the data to a variable as below
|
||||||
|
|
||||||
|
$name = $ou.name
|
||||||
|
$path = $ou.path
|
||||||
|
|
||||||
|
#Account will be created in the OU provided by the $OU variable read from the CSV file
|
||||||
|
New-ADOrganizationalUnit `
|
||||||
|
-Name $name `
|
||||||
|
-path $path `
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
#Import active directory module for running AD cmdlets
|
||||||
|
#Author: Robert Allen
|
||||||
|
#Website: activedirectrypro.com
|
||||||
|
|
||||||
|
Import-Module activedirectory
|
||||||
|
|
||||||
|
#Store the data from ADUsers.csv in the $ADUsers variable
|
||||||
|
$Users = Import-csv c:\it\users.csv
|
||||||
|
|
||||||
|
#Loop through each row containing user details in the CSV file
|
||||||
|
foreach ($User in $Users) {
|
||||||
|
# Read user data from each field in each row
|
||||||
|
# the username is used more often, so to prevent typing, save that in a variable
|
||||||
|
$Username = $User.SamAccountName
|
||||||
|
|
||||||
|
# Check to see if the user already exists in AD
|
||||||
|
if (Get-ADUser -F {SamAccountName -eq $Username}) {
|
||||||
|
#If user does exist, give a warning
|
||||||
|
Write-Warning "A user account with username $Username already exist in Active Directory."
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
# User does not exist then proceed to create the new user account
|
||||||
|
|
||||||
|
# create a hashtable for splatting the parameters
|
||||||
|
$userProps = @{
|
||||||
|
SamAccountName = $User.SamAccountName
|
||||||
|
Path = $User.Path
|
||||||
|
GivenName = $User.GivenName
|
||||||
|
Surname = $User.Surname
|
||||||
|
Initials = $User.Initials
|
||||||
|
Name = $User.Name
|
||||||
|
DisplayName = $User.DisplayName
|
||||||
|
UserPrincipalName = $user.UserPrincipalName
|
||||||
|
Department = $User.Department
|
||||||
|
Description = $User.Description
|
||||||
|
Office = $User.Office
|
||||||
|
OfficePhone = $User.OfficePhone
|
||||||
|
StreetAddress = $User.StreetAddress
|
||||||
|
POBox = $User.POBox
|
||||||
|
City = $User.City
|
||||||
|
State = $User.State
|
||||||
|
PostalCode = $User.PostalCode
|
||||||
|
Title = $User.Title
|
||||||
|
Company = $User.Company
|
||||||
|
Country = $User.Country
|
||||||
|
EmailAddress = $User.Email
|
||||||
|
AccountPassword = (ConvertTo-SecureString $User.Password -AsPlainText -Force)
|
||||||
|
Enabled = $true
|
||||||
|
ChangePasswordAtLogon = $true
|
||||||
|
} #end userprops
|
||||||
|
|
||||||
|
New-ADUser @userProps
|
||||||
|
# Write-Host "The user account $User is created." -ForegroundColor Cyan
|
||||||
|
|
||||||
|
|
||||||
|
} #end else
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
name,path,scope,category,description
|
||||||
|
Marketing_local,"OU=Mylab Groups,DC=mylab,DC=local",DomainLocal,Security,
|
||||||
|
Marketing_Folders,"OU=Mylab Groups,DC=mylab,DC=local",DomainLocal,Security,
|
||||||
|
Accounting_Printers,"OU=Mylab Groups,DC=mylab,DC=local",DomainLocal,Security,
|
||||||
|
Accounting_Folders,"OU=Mylab Groups,DC=mylab,DC=local",DomainLocal,Security,
|
||||||
|
Accounting_Local,"OU=Mylab Groups,DC=mylab,DC=local",DomainLocal,Security,
|
||||||
|
HR_local,"OU=Mylab Groups,DC=mylab,DC=local",DomainLocal,Security,
|
||||||
|
HR_Folders,"OU=Mylab Groups,DC=mylab,DC=local",DomainLocal,Security,
|
||||||
|
IT_Printers,"OU=Mylab Groups,DC=mylab,DC=local",DomainLocal,Security,
|
||||||
|
IT_Folders,"OU=Mylab Groups,DC=mylab,DC=local",DomainLocal,Security,
|
||||||
|
IT_Local,"OU=Mylab Groups,DC=mylab,DC=local",DomainLocal,Security,
|
||||||
|
Management_Printers,"OU=Mylab Groups,DC=mylab,DC=local",DomainLocal,Security,
|
||||||
|
Management_Folders,"OU=Mylab Groups,DC=mylab,DC=local",DomainLocal,Security,
|
||||||
|
PR_Printers,"OU=Mylab Groups,DC=mylab,DC=local",DomainLocal,Security,
|
||||||
|
PR_Folders,"OU=Mylab Groups,DC=mylab,DC=local",DomainLocal,Security,
|
||||||
|
Operations_Printers,"OU=Mylab Groups,DC=mylab,DC=local",DomainLocal,Security,
|
||||||
|
Operations_Folders,"OU=Mylab Groups,DC=mylab,DC=local",DomainLocal,Security,
|
||||||
|
Legal_Printers,"OU=Mylab Groups,DC=mylab,DC=local",DomainLocal,Security,
|
||||||
|
Legal_Folders,"OU=Mylab Groups,DC=mylab,DC=local",DomainLocal,Security,
|
||||||
|
Purchasing_Printers,"OU=Mylab Groups,DC=mylab,DC=local",DomainLocal,Security,
|
||||||
|
Purchasing_Folders,"OU=Mylab Groups,DC=mylab,DC=local",DomainLocal,Security,
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
name,path
|
||||||
|
Mylab Groups,"DC=mylab, DC=local"
|
||||||
|
Mylab Users,"DC=mylab, DC=local"
|
||||||
|
Marketing,"OU=mylab Users,DC=mylab, DC=local"
|
||||||
|
HR,"OU=mylab Users,DC=mylab, DC=local"
|
||||||
|
IT,"OU=mylab Users,DC=mylab, DC=local"
|
||||||
|
Accounting,"OU=mylab Users,DC=mylab, DC=local"
|
||||||
|
Management,"OU=mylab Users,DC=mylab, DC=local"
|
||||||
|
PR,"OU=mylab Users,DC=mylab, DC=local"
|
||||||
|
Operations,"OU=mylab Users,DC=mylab, DC=local"
|
||||||
|
Legal,"OU=mylab Users,DC=mylab, DC=local"
|
||||||
|
Purchasing,"OU=mylab Users,DC=mylab, DC=local"
|
||||||
|
Mylab Computers,"DC=mylab, DC=local"
|
||||||
|
Marketing,"OU=mylab Computers,DC=mylab, DC=local"
|
||||||
|
HR,"OU=mylab Computers,DC=mylab, DC=local"
|
||||||
|
IT,"OU=mylab Computers,DC=mylab, DC=local"
|
||||||
|
Accounting,"OU=mylab Computers,DC=mylab, DC=local"
|
||||||
|
Management,"OU=mylab Computers,DC=mylab, DC=local"
|
||||||
|
PR,"OU=mylab Computers,DC=mylab, DC=local"
|
||||||
|
Operations,"OU=mylab Computers,DC=mylab, DC=local"
|
||||||
|
Legal,"OU=mylab Computers,DC=mylab, DC=local"
|
||||||
|
Purchasing,"OU=mylab Computers,DC=mylab, DC=local"
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue