Advertisement
kcalderw

Untitled

Sep 6th, 2021
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $users = get-aduser -Filter 'Enabled -eq $true' -SearchBase "ou=Students,dc=domain,dc=local" -Properties givenName, sn
  2. $i = 1 $results = ForEach($user in $users) { $password = "SchoolName$i" $user | Set-AdAccountPassword -Reset -NewPassword (ConvertTo-SecureString -String $password -AsPlainText -Force) $i++ [pscustomobject]@{ 'First Name' = $user.givenName 'Last Name' = $user.sn 'E-Mail' = $user.userPrincipalName 'Password' = $password } } $results | Export-Csv -Path c:\temp\5thpasswords.csv -NoTypeInformation
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement