Skip to content

Instantly share code, notes, and snippets.

View michaelrice136's full-sized avatar

Michael Rice michaelrice136

View GitHub Profile
@michaelrice136
michaelrice136 / New-Password.ps1
Created March 29, 2016 13:05
Generate a new password using PowerShell
function New-Password ($length)
{
[string]$Password = ''
[array]$lower = @('a','b','c','d','e','f','g','h','i','j','k','l','n','m','n','o','p','q','r','s','t','u','v','w','x','y','z')
[array]$upper = @('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z')
[array]$symbol = @('!','"','£','$','%','^','&','*','(',')',',','.','@','#')
[array]$num = @('1','2','3','4','5','6','7','8','9','0')
[array]$rand = @($lower,$upper,$symbol,$num)
for ($i = 1; $i -lt $length+1; $i++)
@michaelrice136
michaelrice136 / GetADUsersLockedOutORPasswordExpired.ps1
Created March 29, 2016 10:28
Get all AD users that are locked out or have expired passwords
Get-ADUser -Filter * -Properties PasswordExpired, LockedOut | ? { `
($_.PasswordExpired -EQ $True) -OR `
($_.LockedOut -EQ $True) } | Format-Table
@michaelrice136
michaelrice136 / ExtendADUserPasswordExpiry.ps1
Created March 29, 2016 09:57
Extend password expire date for all AD users to max domain policy time period
$Users = Get-ADUser -Filter * -properties pwdlastset
foreach ($user in $users)
{
$User.pwdlastset = 0
Set-ADUser -Instance $User
$user.pwdlastset = -1
Set-ADUser -instance $User
}