Friday, December 2, 2011

A PowerShell script to determine if accounts are locked

With all of the service accounts that SharePoint 2010 uses and the fact that our infrastructure people are useless, I created this little PowerShell script so I could quickly identify any issues with our service accounts:

cls

$accounts = "sps10_config,sps10_farm,sps10_services,sps10_apps,sps10_sql"

foreach ($account in $accounts.Split(",")){
Write-Host "$account - " -NoNewLine
NET USER $account /DOMAIN | FIND /I "Account active"
}

Write-Host "Press any key to continue ..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")