none
Powershell script to check if an email address exists and is already in use in Active Directory and Exchange RRS feed

  • Question

  • Hi,
    Need help with a script to check if an email address (primary or secondary) is already assigned to a user.
    Accept email address as input from user, search for the address in AD and then action based on result.
    I am a newbie but this is what I could think of.
    $EmailInput = Read-Host "Enter email Address"
    $Result = (Get-User -Identity $EmailInput).Name
    if ($Result -eq $Null) { Write-Host "Email Address Exists!" }
    else { Write-Host "Email Address is Available to use!" }

    Tuesday, June 28, 2011 7:31 AM

All replies

  • You can use get-recipient <email address> to see if any recipient has that address.  That will cover addresses used by users, groups, and contacts.

    You miight also want to validate that the domain part matches an accepted domain.


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
    Tuesday, June 28, 2011 10:37 AM