Add basic user add / group add mechanisms
This commit is contained in:
parent
8ee990cca2
commit
9409e59f57
@ -1,4 +1,6 @@
|
||||
# Functions first
|
||||
Import-Module ActiveDirectory
|
||||
|
||||
# Genpass génere un mdp aléatoire
|
||||
function GenPass {
|
||||
|
||||
$TokenSet = @{
|
||||
@ -21,8 +23,27 @@ function GenPass {
|
||||
|
||||
}
|
||||
|
||||
function New-ADUser {
|
||||
$userPass = (GenPass)
|
||||
|
||||
|
||||
$detailsUser = @{
|
||||
Name = 'Tech-N1'
|
||||
AccountPassword = $userPass
|
||||
Enabled = $true
|
||||
ChangePasswordAtLogon = $false
|
||||
PasswordNeverExpires = $true #On fait en sorte qu'il n'expire pas
|
||||
|
||||
}
|
||||
}
|
||||
New-ADUser @detailsUser #On cree l'user...
|
||||
|
||||
#...puis on l'ajoute aux bons groupes
|
||||
$User = 'Tech-N1'
|
||||
|
||||
$Groups = @("Account Operators","Print Operators")
|
||||
|
||||
ForEach ($Group in $Groups) {
|
||||
|
||||
Add-ADPrincipalGroupMembership $User -MemberOf $Group
|
||||
|
||||
}
|
||||
|
||||
Write-Host "L'utilisateur $User a bienété cée et ajouté aux groupes 'Account operators' et 'Print Operators'. Son mot de passe est $userPass"
|
Loading…
Reference in New Issue
Block a user