Created
July 4, 2024 10:38
-
-
Save rupertbg/f56cd249bcb45028ccca08c190d926f3 to your computer and use it in GitHub Desktop.
POV: You've deleted an active directory computer account and you don't have recycle bin turned on
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a new matching computer account in the Active Directory then.. | |
# Reset the computer machine password as a domain account | |
$DomainName = "example.com" | |
$DomainUser = "[email protected]" | |
$DomainPassword = "yoursupergreatpassword" | |
$DomainController = "dc1.example.com" | |
$SecurePassword = ConvertTo-SecureString -String $DomainPassword -AsPlainText -Force | |
$Credential = New-Object System.Management.Automation.PSCredential ($DomainUser, $SecurePassword) | |
Reset-ComputerMachinePassword -Server $DomainController -Credential $Credential | |
# Repair the computer secure channel using a local account | |
$User = "Administrator" | |
$Password = "thereallystrongadministratorpassword" | |
$SecurePassword = ConvertTo-SecureString -String $Password -AsPlainText -Force | |
$Credential = New-Object System.Management.Automation.PSCredential ($User, $SecurePassword) | |
Test-ComputerSecureChannel -Repair -Credential $Credential |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment