If you’re creating or modifying users with a powershell script you might want to check to see if they exist first.

Here is some powershell code that will do just that for you:

$account = "username"

if ( -not (Get-ADUser -LDAPFilter "(sAMAccountName=$account)"))
{ Write-Host "Create the account!" }
else
{ Write-Host "Already there" }

For this to work you will need to have the PowerShell AD modules installed and AD Web Services operational.