PowerShell 24: Active Directory Provisioning

preview_player
Показать описание
Provisioning AD user accounts, global security groups and organizational units with powershell.



Рекомендации по теме
Комментарии
Автор

Source Code 1:
function Batch_MLP
{
$OU_Name = "1_MLP_Main_Chars";
$Group_Name = "MLP-FIM-Admins";
$DomainPath = "DC=BattleStars, DC=fleet";
$DomainName = "BattleStars.fleet";
$LOCATION = "OU=" + $OU_Name + ", " + $DomainPath;

Write-Host("`n1. Creating OU `"" + $OU_Name + "`". Location = `"" + $LOCATION + "`".");
New-ADOrganizationalUnit -Name $OU_Name -Path $DomainPath;

Write-Host("`nWaiting 5 seconds for replication.");
for($z = 0; $z -LT 5; $z++)
{
Write-Host(" .") -NoNewline;
Start-Sleep -s 1;
}

Write-Host("`n2. Creating Global Security Group " + $OU_Name + ". Location = `"" + $LOCATION + "`".");
New-ADGroup -Name $Group_Name -SamAccountName $Group_Name -GroupCategory Security -GroupScope Global `
-Path $LOCATION -DisplayName $Group_Name -Description ("Administrators for OU `"" + $OU_Name + "`".");

Write-Host("`nWaiting 5 seconds for replication.");
for($z = 0; $z -LT 5; $z++)
{
Write-Host(" .") -NoNewline;
Start-Sleep -s 1;
}

$City = "Equestria";
$Office = "Building 444";
$Company = "Ponies R US";

$The_Users = @( #Name-DisplayName, UPN, SamAcct, Email, Title, Department, Description
("Twilight Sparkle", "twilight_sparkle", "SparkT", "Twilight.Sparkle", "Chief Magician", "Unicorns", "Understudy to Princess C.", "10000444"),
("Rainbow Dash", "rainbow_dash", "DashRa", "Rainbow.Dash", "Weather Manager", "Ponies", "Outgoing overachiever.", "10000777"),
("Fluttershy", "flutter_shy", "ShyFlu", "Flutter.Shy", "Animal Caregiver", "Ponies", "Kind animal lover", "10000777"),
("Apple Jack", "apple_jack", "AppleJ", "Apple.Jack", "Argiculture Engineer", "Ponies", "Texas cowgirl", "10000777"),
("Pinkie Pie", "pinkie_pie", "PiePin", "Pinkie.Pie", "Festivities Planner", "Ponies", "Party animal.", "10000333"),
("Rarity", "rarity", "Rarity", "Rarity", "Chief Set Designer", "Ponies", "Fashionista.", "10000222")
);

Write-Host("`n3. Creating Users inside OU `"" + $OU_Name + "`". Also adding them to GSG `"" + $Group_Name + "`".");
for($x = 0; $x -LT $The_Users.Count; $x++)
{

Write-Host("Creating USER " + ($x+1) + ". " + $The_Users[$x][0] + "");

$FirstName = ($The_Users[$x][0].Split(" "))[0];
$LastName = ($The_Users[$x][0].Split(" "))[1];

-Path $LOCATION -City $City -Office $Office -Company $Company `
-HomePage $Web -OfficePhone $The_Users[$x][7] `
-ProfilePath ("\\Galactica\PROFILES\" + $The_Users[$x][1]) `
-HomeDirectory ("\\Galactica\PROFILES\" + $The_Users[$x][1]) `
-HomeDrive "Z:" `
-GivenName $FirstName `
-Surname $LastName `
-Name $The_Users[$x][0] `
-DisplayName $The_Users[$x][0] `
-UserPrincipalName ($The_Users[$x][1] + "@" + $DomainName) `
-SamAccountName $The_Users[$x][2] `
-EmailAddress ($The_Users[$x][3] + "@" + $DomainName) `
-Title $The_Users[$x][4] `
-Department $The_Users[$x][5] `
-Description $The_Users[$x][6] `
-OtherAttributes @{'msTSProperty01'="Staff";
'msTSManagingLS'="Alicorns";


'msTSManagingLS4'="Ponies";


Add-ADGroupMember $Group_Name -Members ( $The_Users[$x][2]);
}

}

<# #>
#Title: Account-Provisioning
#Description: Populates AD with Global Security Groups, OUs and User Accounts.
# For 2019 CORE Server DC + Exchange Test Environment.
#Date: 08/25/2020
#Revision: 1.0
#Author: Carly S. Germany

OneByteAtATime
Автор

I didn't expect all of favourite movies and manga inside this video, with clear explanation, what a well done.

felixmcs