Check UserID for Differences

January 4, 2013

What prompted me to look for this solution was an error we received while trying to run –

Get-CSUser TBOLTON

I received this error –

Management object not found for identity "tbolton".
+ CategoryInfo : InvalidData: (tbolton:UserIdParameter) [Get-CsUser], ManagementException
+ FullyQualifiedErrorId : Identity,Microsoft.Rtc.Management.AD.Cmdlets.GetOcsUserCmdlet
+ PSComputerName : BigDog.ad

The issue turned out to be the Alias Setting on the General Page in Exchange.  For what ever reason the entry there was BOLTONTIM

Today I found what Get-CSUser was keying off of in AD, it was keying off of, “MailNickName”.

# Used To Check for any differences in a UserID

# Example - PS C:\>Check-UserID TBOLTON

Function Check-UserID {
param(
[parameter(Mandatory = $true)]
[String] $UID)
$User=(Get-ADUser $UID -Properties *)
$UserSAM=$User.SamAccountName
$UserName=$User.Name
$UserCN=$User.CN
$UserNickName=$User.MailNickName
# Report if there are differences
if (($UserSAM -eq $UserName) -and ($UserName -eq $UserNickName))
{
"`r`n"
Write-Host -foregroundcolor Green "The UserId"  $UID  "WAS a match"
"`r`n"
Write-Host -foregroundcolor Green "SAM Account:  " $UserSAM
Write-Host -foregroundcolor Green "User Name: -- " $UserName
Write-Host -foregroundcolor Green "CN: --------- " $UserCN
Write-Host -foregroundcolor Green "Mail ALias: - " $UserNickName
"`r`n"
} else {
"`r`n"
     Write-Host -foregroundcolor Red "The UserId"  $UID  "did NOT match"
"`r`n"
Write-Host -foregroundcolor Red "SAM Account:  " $UserSAM
Write-Host -foregroundcolor Red "User Name: -- " $UserName
Write-Host -foregroundcolor Red "CN: --------- " $UserCN
Write-Host -foregroundcolor Red "Mail ALias: - " $UserNickName
"`r`n"
    }
}

——————————————————————————–
In this example my account is intentionally set up wrong while the first account is set up correctly.
 CheckUserID