Now exports users to a csv file
This commit is contained in:
parent
74d891415f
commit
1ea4f9e09c
@ -15,6 +15,9 @@ switch ($modExiste) {
|
|||||||
Default {Import-Module ActiveDirectory;Import-Module PSWriteColor}
|
Default {Import-Module ActiveDirectory;Import-Module PSWriteColor}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#On crée le CSV pour y stocker les ID
|
||||||
|
$pcName = (Get-ComputerInfo).CSName
|
||||||
|
Set-Content "C:\techLogins-$pcName.csv" -Value "Username,Password"
|
||||||
|
|
||||||
########### Fonctions ###########
|
########### Fonctions ###########
|
||||||
function GenPass { #Genere un mdp aléatoire selon les parametres indiqués
|
function GenPass { #Genere un mdp aléatoire selon les parametres indiqués
|
||||||
@ -84,6 +87,9 @@ ForEach($user in $userList){
|
|||||||
Default {}
|
Default {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$newCsvLine = @([PSCustomObject]@{Username = $user; Password = $userPass}
|
||||||
|
$newCsvLine | Export-CSV "C:\techLogins-$pcName.csv" -Append -NoTypeInformation -Encoding UTF8
|
||||||
|
|
||||||
ForEach ($Group in $Groups) {
|
ForEach ($Group in $Groups) {
|
||||||
|
|
||||||
Add-ADPrincipalGroupMembership $User -MemberOf $Group
|
Add-ADPrincipalGroupMembership $User -MemberOf $Group
|
||||||
|
Loading…
Reference in New Issue
Block a user