Now exports users to a csv file

This commit is contained in:
Sébastien QUEROL 2025-01-02 17:18:15 +01:00
parent 74d891415f
commit 1ea4f9e09c

View File

@ -15,6 +15,9 @@ switch ($modExiste) {
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 ###########
function GenPass { #Genere un mdp aléatoire selon les parametres indiqués
@ -83,6 +86,9 @@ ForEach($user in $userList){
"Tech-N3"{$Groups = @($grpDomainAdm)}
Default {}
}
$newCsvLine = @([PSCustomObject]@{Username = $user; Password = $userPass}
$newCsvLine | Export-CSV "C:\techLogins-$pcName.csv" -Append -NoTypeInformation -Encoding UTF8
ForEach ($Group in $Groups) {