Scripts

Get Event Logs (With GUI)


Reset Password in Active Directory


$user = read-host "Enter a username: "
$newPassword = read-host "Enter a new password: " -AsSecureString
$credential = Get-Credential
Set-ADAccountPassword -Identity $user -NewPassword $newPassword -Reset -Credential $credential
Set-ADUser -Identity $user -ChangePasswordAtLogon $true -Credential $credential
Unlock-AdAccount -Identity $user -Credential $credential

Edit Description in Active Directory


$computerName = Read-Host "Enter a computer name: "
$desc = Read-Host "Enter the description: "
$cred = Get-Credential
Set-ADComputer -Identity $computerName -Credential $cred -Description $desc
write-host "Description has been changed"

Remove Computer From Active Directory and SCCM


$assetTag = Read-Host "Enter the Asset Tag: "

#Authenticate
$credential = Get-Credential -Message "User credentials are required to perform this action"

#Remove from AD
Get-ADComputer -Identity $assetTag -Credential $credential | Remove-ADObject -Recursive

#remove from SCCM
Set-Location 'C:\Program Files (x86)\ConfigMgr Console\bin'
Import-Module ".\ConfigurationManager.psd1"
New-PSDrive -Name "SCCM" -PSProvider "CMSite" -Root "server" -Description "Primary site"
Set-Location "SCCM:"
Remove-CMDevice -Name $assetTag
Write-Host "Computer removed"

View All (GitHub) ← return