From 2f463d02d70445f45a20f04787578ac937a6a4de Mon Sep 17 00:00:00 2001 From: mjfernez Date: Sat, 19 Feb 2022 15:35:26 -0500 Subject: Add AD scripts and bitwarden to pass script --- AD-powershell-tools/ad-bulk-reset.ps1 | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 AD-powershell-tools/ad-bulk-reset.ps1 (limited to 'AD-powershell-tools/ad-bulk-reset.ps1') diff --git a/AD-powershell-tools/ad-bulk-reset.ps1 b/AD-powershell-tools/ad-bulk-reset.ps1 new file mode 100644 index 0000000..aa16515 --- /dev/null +++ b/AD-powershell-tools/ad-bulk-reset.ps1 @@ -0,0 +1,27 @@ +# Usage: ad-bulk-reset.ps1 +Import-Module ActiveDirectory + +function Gen-Random-Password { + $str = "" + for ($i = 0; $i -lt 24 ; $i++) { + $rand = Get-Random -Minimum 32 -Maximum 127 + $str += [char]$rand + } + $newpwd = ConvertTo-SecureString -String [String]$str -AsPlainText -Force + return $newpwd +} + +# Import users from CSV +$csv = Get-Content $args[0] + +ForEach ($user in $csv) { + $newPassword = Gen-Random-Password + + # Reset user password. + Set-ADAccountPassword -Identity $user -NewPassword $newPassword -Reset + + # Force user to reset password at next logon. + # Remove this line if not needed for you + #Set-AdUser -Identity $user -ChangePasswordAtLogon $true + Write-Host $user"'s password has been reset" +} -- cgit v1.2.3