soldier wearing brown helmet holding assault rifle during daytime
Photo by Pixabay on Pexels.com
# Find if an email address is available for use.
function Get-EmailAvailability
{
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true)]
[string] $EmailAddress
)
$ConstructEmail = "'" + 'smtp:'+$EmailAddress + "'"
$rcpt = Get-ADUser -Filter "proxyAddresses -eq $ConstructEmail" -Properties proxyAddresses | select Displayname, proxyAddresses, UserPrincipalName
$RcptType = $rcpt.UserPrincipalName
if($RcptType -eq $null)
{
#write-host ($RcptType.UserPrincipalName + " is not Present") -ForegroundColor Green
write-host ($EmailAddress + " is not Present") -ForegroundColor Red
}
else
{
write-host ($EmailAddress + " is Present") -ForegroundColor Green
}
}

Copy this to a your desktop and name it EmailAvailability.ps1