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 Disable SELINUX on CentOS 8

SELinux is a sort of system-call firewall, where processes are in their run spaces. When…

Error: Windows cannot load extensible counter DLL MSSQLSERVER, the first DWORD in data section is the Windows error code.

 Resolution:   Give everyone read/execute access to binn\sqlctr80.dll or msmdctr90.dll   # Set file$sqlctr =…

PowerShell: Download and Expand Zip File – Legacy Compatible

function downloadFile{ param( $url, $tempFolder="C:\Temp" ) try{ $fileName=split-path $url -leaf $tempFile = "$tempFolder\$fileName" try{[Net.ServicePointManager]::SecurityProtocol =…