While preparing for my new article(s) on Communications Server “14″ PowerShell, I had to run some tests using the new CS Management Shell. Specifically, I was looking for AD users that have not yet been enabled in CS.
The CsEnabled property is present in both the Get-CsUser and Get-CsAdUser cmdlets so I started off with the latter:
PS C:\> Get-CsAdUser -Filter {CsEnabled -eq $False} | ft
SamAcco Sid SidHist Passwor UserAcc UserPri Primary Id AltSecu Assista
untName ory dLastSe ountCon ncipalN GroupId rityIde nt
t trol ame ntities
——- — ——- ——- ——- ——- ——- — ——- ——-
Admi… S-1-… {} …ount 513 CN=A… {}
Guest S-1-… {} …word 514 CN=G… {}
krbtgt S-1-… {} …ount 513 CN=k… {}
So far so good. When I switch over to use Get-CsUser, it returned no results:
PS C:\> Get-CsUser -Filter {CsEnabled -eq $False} | ft
WARNING: No result found.
Curious as to why this turns out to be the case, I changed the filter to $true:
PS C:\> Get-CsUser -Filter {CsEnabled -eq $true} | ft
SamAcco UserPri FirstNa LastNam Windows Sid LineSer Origina AudioVi IPPBXSo
untName ncipalN me e EmailAd verURI torSid deoDisa ftPhone ame dress bled Routing Enabled
——- ——- ——- ——- ——- — ——- ——- ——- ——-
fchan fcha… Freddy Chan S-1-… False False
wmue… wmue… Wendy Mueller S-1-… False False
wfou… wfou… wave four… S-1-… False False
As expected, CS-enabled users showed up in the query. The same set of results was returned with Get-CsAdUser.
Although both cmdlets are designed to work with user accounts, Get-CsADUser is the sole one that will return all aspects of an AD account information regardless of whether an account is Cs-enabled or not. In contrast, Get-CsUser deals explicitly with accounts that are *already* Cs-enabled.
The reason behind this is that attributes specific to CS are added to an account when it is Cs-enabled. The CsEnabled is one property that allows Get-CsUser to correctly determine the CS status (configured using Set-CsUser or Enable-CsUser). Through Disable-CsUser, the Cs-related attributes are permanently deleted while keeping everything else known about the AD account. This effectively means that the account is no longer enabled for CS. In order to maintain these CS specific information, you should use the Disconnect-CsUser.
Besides the CsEnabled property, the following is a list of overlapping attributes that are present in both Get-CsUser and Get-CsAdUser:
CsEnabled
DisplayName
Identity
SamAccountName
SipAddress
TenantId
UserPrincipalName
So the conclusion is - use the right cmdlet with care!
See “Properties Returned By Get-CsUser and Get-CsAdUser” for more information on this subject (where I had the pleasure to work with Greg from the CS PowerShell team to investigate this).
Technorati tags: PowerShell, LCS/OCS/CS14, Community/User Groups, Communications Server 14