D(one) IT

IT Tips, Tricks & Such

Lync Script – Users with Desktop sharing

I frequent the Lync TechNet forums: http://social.technet.microsoft.com/Forums/en-US/category/lync and was recently asked how one would get a report for all users that have Desktop Sharing enabled.

I took the script from here: http://blogs.technet.com/b/nexthop/archive/2010/06/07/scriptuserpolicyassignments.aspx

Modified it to run for all users, detect only the Conferencing policy and write a line when EnableAppDesktopSharing is equal to Desktop for the user.

Sample output:
Jay Pritchett / Conferencing Policy: Global policy / Sharing: Desktop

Save the following as a ps1 file and run the script from the Lync Management Shell (example C:\Scripts\Get-UsersAllowedDesktop.ps1):

$y = @()

$userlist = Get-CsUser -ResultSize Unlimited
$x = Get-CsConferencingPolicy 

foreach ($user in $userlist)

if ($user.ConferencingPolicy -eq $Null)
        $site = (Get-CsSite | Where-Object {$_.Pools -contains $user.RegistrarPool}).Identity
        foreach ($i in $x)
            {$y += ($i.Identity)}
                if ($y -contains "$site")
                    $Desktop = Get-CsConferencingPolicy -identity "$site" | Select -expandproperty EnableAppDesktopSharing 
                    $output = $user.DisplayName + " / Conferencing Policy: site:$site / Sharing: $Desktop"
                   $Desktop = Get-CsConferencingPolicy -identity Global | Select -expandproperty EnableAppDesktopSharing
                   $output = $user.DisplayName + " / Conferencing Policy: Global policy / Sharing: $Desktop"
   $ID = "tag:" + $user.ConferencingPolicy
   $Desktop = Get-CsConferencingPolicy -identity $ID | Select -expandproperty EnableAppDesktopSharing
   $output = $user.DisplayName + " / Conferencing Policy: " + $user.ConferencingPolicy + " / Sharing: $Desktop"
if ($Desktop -eq "Desktop") 

$site = $Null
$Desktop = $Null
$output = $Null

The bulk of the script is to deal with a user’s Effective Policy because the get-csuser Cmdlet only shows Per-User Polices.

Get-CsUser -Identity Jayp |fl name, *policy

Name : Jay Pritchett
ExchangeArchivingPolicy : Uninitialized
VoicePolicy : CalgaryVoicePolicy
MobilityPolicy : BlockMobilityPolicy
ConferencingPolicy :
PresencePolicy :
VoiceRoutingPolicy :
LocationPolicy :
ClientPolicy :
ClientVersionPolicy :
ArchivingPolicy :
LegalInterceptPolicy :
PinPolicy :
ExternalAccessPolicy : BlockExtenralPolicy
HostedVoicemailPolicy :
PersistentChatPolicy :
UserServicesPolicy : UCSEnabled
ExperiencePolicy :

A rundown of the script.

  1. Grab all Lync users
  2. Individually check if a user has a Per-User Policy assigned, if not then determine if the user’s pool has a Site Policy, if not assume Global Policy is assigned.
  3. Run specific query determined by which type of policy is assigned
  4. Output formatted info
  5. Move to the next user in the list

This script can be easily modified to query different properties and/or policies.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: