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.
0.000000
0.000000
Like this: Like Loading...
This entry was posted on Friday, January 4th, 2013 at 5:20 pm and is filed under Exchange , Powershell , Tips and Tricks . You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response , or trackback from your own site.
Post navigation
« Previous Post
Thanks Claus!
I had forgotten about the Here-String @” “@ I thought it was only for Email Body within the script. I did not realize that you could use it for “any” text.
Another option
Function Check-UserID {
param(
[parameter(Mandatory = $true)]
[String] $UID)
if (-not (Get-Module -Name ActiveDirectory)) {
Import-Module ActiveDirectory
}
$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 $Usersam) -and ($UserName -eq $UserNickName)) {
$text = @”
The UserId $UID WAS a match
SAM Account: $UserSAM
User Name: — $UserName
CN: ——— $UserCN
Mail ALias: – $UserNickName
“@
Write-host -ForegroundColor Green $text
}
else {
$text = @”
The UserId $UID did NOT match
SAM Account: $UserSAM
User Name: — $UserName
CN: ——— $UserCN
Mail ALias: – $UserNickName
“@
Write-host -ForegroundColor Red $text
}
}
Check-UserID ctn