Starting to collect some PowerShell scripts for references. There are lots of them can be found from the references section.

Export a Computer List from Active Directory


Step 1: Run Powershell ISE

Open the Powershell ISE → Run the following script, adjusting the path for the export:

Step 2: Source Code (One Line)

Get-ADComputer -Filter * -Property * | Select-Object Name,OperatingSystem,OperatingSystemVersion,ipv4Address | Export-CSV ADcomputerslist.csv -NoTypeInformation -Encoding UTF8

Reset Domain User’s Password

1. Using Powershell

Set-ADAccountPassword -Identity admin2 -Reset -NewPassword (ConvertTo-SecureString -AsPlainText "Cyberark1" -Force)
Set-ADAccountPassword -Identity admin3 -Reset -NewPassword (ConvertTo-SecureString -AsPlainText "Cyberark1" -Force)
Set-ADAccountPassword -Identity auditor1 -Reset -NewPassword (ConvertTo-SecureString -AsPlainText "Cyberark1" -Force)
Set-ADAccountPassword -Identity auditor2 -Reset -NewPassword (ConvertTo-SecureString -AsPlainText "Cyberark1" -Force)
Set-ADAccountPassword -Identity test1 -Reset -NewPassword (ConvertTo-SecureString -AsPlainText "Cyberark1" -Force)
Set-ADAccountPassword -Identity test2 -Reset -NewPassword (ConvertTo-SecureString -AsPlainText "Cyberark1" -Force)
Set-ADAccountPassword -Identity test3 -Reset -NewPassword (ConvertTo-SecureString -AsPlainText "Cyberark1" -Force)
Set-ADAccountPassword -Identity vaultadmin1 -Reset -NewPassword (ConvertTo-SecureString -AsPlainText "Cyberark1" -Force)
Set-ADAccountPassword -Identity vaultadmin2 -Reset -NewPassword (ConvertTo-SecureString -AsPlainText "Cyberark1" -Force)

2. Use Command Prompt

net user /domain USERNAME NEWPASS.
Run command prompt as administrator:

C:\Windows\system32>net user /domain admin2 Cyberark1
The command completed successfully.

C:\Windows\system32>
Replace USERNAME and NEWPASS with the actual username and a new password for this user.If the actual username consists of more than two words, place it inside quotation marks.

References

from Blogger http://blog.51sec.org/2021/02/windows-powershell-script-collection.html

By Jon

Leave a Reply

%d bloggers like this: