Posted On November 3, 2021

PowerShell: Set PasswordNeverExpires on SamAccountName

kimconnect 0 comments
blog.KimConnect.com >> Codes >> PowerShell: Set PasswordNeverExpires on SamAccountName

Quick 1-liner Code

$accounts=@(
    'orange',
    'apple',
    'pear',
    'dog',
    'cat',
    'dinosaur',
    'chicken',
    'cow',
    'yomama',
    'yodada'
)
$accounts|%{try{Set-ADUser -Identity $_ -PasswordNeverExpires $false;write-host "$_ : done"}catch{write-warning "$_ : error"}}

Result:

'orange': done
'apple': done
'pear': done
'dog': done
'cat': done
'dinosaur': done
'chicken': done
'cow': done
'yomama': done
'yodada': done

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

Quick 1-Liner to List Domain Controllers and ReadOnly Statuses

PS C:\WINDOWS> Get-ADDomainController -Filter * | select Name,IsReadOnlyName       IsReadOnly----       ----------MONKEY       FalseBABOON       FalseGIRAFFE      FalseLION   FALSEKIMCONNECT   TrueKIMDISCONNECT TrueWHAT        TrueNOWAY        TrueWEBDC01      TrueWEBDC02      TrueSSO01        True

PowerShell: Check DotNet Framework on Windows

function checkDotNetVersions{ # General info: # - Powershell 2.0 latest SSL version support is TLS…

PowerShell: Microsoft Failover Cluster Discovery Version 0.10

<# .Sypnosis: Microsoft_Clusters_Discovery_v.0.10.ps1 What it does: - Installs Microsoft Failover Cluster PowerShell module on the…