diff --git a/AD.ps1 b/AD.ps1 index cbf7942..9338e9e 100644 --- a/AD.ps1 +++ b/AD.ps1 @@ -9,6 +9,20 @@ New-ADOrganizationalUnit -Name "STAGIAIRE" -Path "DC=chromatic,DC=moe" -Protecte New-ADOrganizationalUnit -Name "ADMINISTRATION" -Path "DC=chromatic,DC=moe" -ProtectedFromAccidentalDeletion $true New-ADOrganizationalUnit -Name "CHAUFFEUR" -Path "DC=chromatic,DC=moe" -ProtectedFromAccidentalDeletion $true +# Group Creation +New-ADGroup -Name "G_COMPTABLE" -Path "OU=COMPTABLE,DC=chromatic,DC=moe" -GroupScope Global -GroupCategory Security +New-ADGroup -Name "G_STAGIAIRE" -Path "OU=STAGIAIRE,DC=chromatic,DC=moe" -GroupScope Global -GroupCategory Security +New-ADGroup -Name "G_ADMINISTRATION" -Path "OU=ADMINISTRATION,DC=chromatic,DC=moe" -GroupScope Global -GroupCategory Security +New-ADGroup -Name "G_CHAUFFEUR" -Path "OU=CHAUFFEUR,DC=chromatic,DC=moe" -GroupScope Global -GroupCategory Security + # User Creation -$password = Get-RandomPassword -New-ADUser -Name "Emerald" -Description "Administrateur reseau" -Path "OU=ADMINISTRATION,DC=chromatic,DC=moe" -AccountPassword $(ConvertTo-SecureString $password -AsPlainText -Force) -ChangePasswordAtLogon $true -PasswordNeverExpires $false -Enabled $true \ No newline at end of file +New-ADUser -Name "Emerald" -Description "Administrateur reseau" -AccountPassword $(ConvertTo-SecureString (Get-RandomPassword) -AsPlainText -Force) -ChangePasswordAtLogon $true -PasswordNeverExpires $false -Enabled $true +New-ADUser -Name "Stagiaire1" -AccountPassword $(ConvertTo-SecureString (Get-RandomPassword) -AsPlainText -Force) -ChangePasswordAtLogon $true -PasswordNeverExpires $false -Enabled $true +New-ADUser -Name "Comptable1" -AccountPassword $(ConvertTo-SecureString (Get-RandomPassword) -AsPlainText -Force) -ChangePasswordAtLogon $true -PasswordNeverExpires $false -Enabled $true +New-ADUser -Name "Chauffeur1" -AccountPassword $(ConvertTo-SecureString (Get-RandomPassword) -AsPlainText -Force) -ChangePasswordAtLogon $true -PasswordNeverExpires $false -Enabled $true + +# Adding Users to Groups +Add-ADGroupMember -Identity "G_ADMINISTRATION" -Members "Emerald" +Add-ADGroupMember -Identity "G_STAGIAIRE" -Members "Stagiaire1" +Add-ADGroupMember -Identity "G_COMPTABLE" -Members "Comptable1" +Add-ADGroupMember -Identity "G_CHAUFFEUR" -Members "Chauffeur1" \ No newline at end of file