Posted On September 21, 2022

Changing User Password Using Command Lines or PowerShell

kimconnect 0 comments
blog.KimConnect.com >> Windows >> Changing User Password Using Command Lines or PowerShell
# Command-line method
net user usernamehere newpasswordhere

# Powershell Method 1 - via ActiveDirectory module
$username="USERNAMEHERE"
$newPassword="NEWPASSWORDHERE"
$encryptedPass= ConvertTo-SecureString $newPassword -AsPlainText -Force 
Set-ADAccountPassword -Identity $username -NewPassword $encryptedPass -Reset

# Powershell method 2 - via ASDI
$userid = [ADSI]"LDAP://CN=USERNAME,OU=Users,DC=DOMAIN,DC=Local"
$userid.psbase.invoke("SetPassword",'NEWPASSWORDHERE')
$userid.psbase.CommitChanges()

Leave a Reply

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

Related Post

How to Know if Your Colleague is a God (Like Thor)?

Sometimes, I sit back and watch the mind games in politics, companies, churches, and even…

PowerShell: Download Dot Net 4.7.2

# Illustration: download Dot Net 4.7 Run-time from behind a proxy and showing progress barfunction…

PowerShell: Checking Duplicating Identifiers Among ADFS Relying Party Trusts

function getDuplicatingIfd{ write-host "Checking each relying party trust for any duplicates of identifiers..." $trusts=Get-AdfsRelyingPartyTrust $allTrustNames=$trusts.Name…