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

How to Import Files Into a Docker Container

1. Use SCP to copy files to the remote server while logged onto the local…

PowerShell: Move Virtual Machine Storage Using VMM

# moveVmStorageUsingVmm.ps1 # Version 0.01 $vmNames=@( 'TESTVM0001', 'TESTVM0002', 'TESTVM0003' ) $storageLocations=@( 'C:\ClusterStorage\BLOB001', 'C:\ClusterStorage\BLOB002', 'C:\ClusterStorage\BLOB003' )…

PowerShell: Update Windows Computers

There's a more updated version available. <# Update-Windows-Computers-v0.11.ps1 # # Purpose: trigger Microsoft Updates on…
Other project: DragonCoin.com