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

PowerShell: How To Bypass Double Hop Problems

# This is a working example of hoping without delegation. Fresh creds can be passed…

Enable Serial over Ethernet

enableconfig tplatform console serialendcopy run startreload

Invoke T-SQL on Multiple Servers

$computersAndCredentials=@{ 'SQL01'=@{'intranet\sql01Admin'='PASSWORD'} 'SQL02'=@{'intranet\sql02Admin'='PASSWORD'} 'SQL03'=@{'intranet\sql03Admin'='PASSWORD'} 'SQL04'=@{'intranet\sql04Admin'='PASSWORD'} } $tSql=" --Update the Setting with a new value: USE…