Powershell Unlock Account – loop

Powershell script to view user account and unlock the account:

[Note: must run as Domain admin to view account and have ActiveDirectory module installed]

Screenshot:

ADuserinfo

Code:


Import-Module ActiveDirectory
$val = 0
while ($val -lt 1)
{
$username = Read-Host -Prompt 'Input the user name'
get-aduser -identity $username -properties passwordlastset, passwordexpired, lockedout, lastlogon, scriptpath

Write-Host -ForegroundColor YELLOW 'Do you need to unlock?'
$confirmation = Read-Host "y/n:"
if ($confirmation -eq 'y') {
unlock-adaccount -identity $username
Write-Host -ForegroundColor YELLOW 'Unlocked :)'
} else {
Write-Host -ForegroundColor YELLOW 'Okay'
Write-Host '------------------------------'
Write-Host '------------------------------'
}
}

 

Get Computer Serial Number, Model, BIOS WMIC

The following is an easy script that searches your domain for the hostname or ip address and retrieves the serial, manufacturer, model, and bios for a computer. Note: You must be domain admin

Screenshot:

Get Computer Serial Number

Code:

:: This bat-file shows serial number, manufacturer and model for a computer
:: Written by JD
:: 12/5/2012
@ECHO --------------------------------------------------------------------
@ECHO This shows serial, manufacturer, model, and bios for a computer
@ECHO --------------------------------------------------------------------
@ECHO OFF 
:TOP
SET /P computername=Enter computername:
echo.
wmic /node:"%computername%" bios get serialnumber
WMIC /node:"%computername%" BIOS Get Manufacturer
WMIC /node:"%computername%" computersystem Get Model
WMIC /node:"%computername%" BIOS Get version
@ECHO --------------------------------------------------------------------
@ECHO Press any key to do new search...
@ECHO --------------------------------------------------------------------
pause >nul
Goto Top