Archive for May, 2011

Find everyone rolling up to me

Yesterday someone asked me to help create a distribution list for everyone reporting to a particular manager (directly or indirectly). Needless to say, that PowerShell makes getting a list of such user accounts a piece of cake!

Here’s the quick script (using AD cmdlets) which I emailed back:

function Get-QADIndirectReport {
param ($Identity)
  # Find all direct reports
  Get-QADUser -Manager $Identity | ForEach-Object {
      # Output direct report
    $_ 
    # Then recursively call this function for all
    # reports of this report
    Get-QADIndirectReport -Identity $_
  }

}

# usage example
Get-QADIndirectReport 'Dmitry Sotnikov'

Basically, AD cmdlets natively can retrieve all direct reports, and I have created a function which keeps going deeper level-by-level getting everyone reporting indirectly as well.

You can then take this a few steps further. For example, say, you want to get a list of users you could then just copy/paste into Outlook. Simply select the Email property from the user objects and ask PowerShell to put semicolon between the addresses:

# get a list of addresses for an email message
(Get-QADIndirectReport 'Dmitry Sotnikov' | 
  Select-Object -ExpandProperty Email) -join '; '

Or you could indeed use the list to populate a group:

# add everyone to a group
Get-QADIndirectReport 'Dmitry Sotnikov' |
  Add-QADGroupMember DmitrysReports

Or you could further restrict the list by City, Department and so on by simply tweaking Get-QADUser parameters in the code above. PowerShell is super-flexible!


My Recent Tweets

RSS My company’s blog

  • Yabe in the Cloud: Deployment Guide
    Since the Play! framework is one of the most popular frameworks among our developers, we thought we should publish another how-to showing how to deploy Play! apps to the Jelastic cloud. It’s pretty easy. We will use the yabe. blog engine as an example. Create an environment 1. Go to Jelastic.com and sign up if you haven’t done it yet or log [...] […]
  • The Jelastic Spotlight
    We are starting something new here on the blog for Fridays. Up until now, we were doing more light-hearted stuff but as we were sitting around talking about the different sweet apps that you, our customers, are deploying, we realized that we should be showcasing the apps and the developers! So, as of today, Fridays [...]
  • Remote Access to MySQL in Jelastic: Import/Export Dump Files in a Few Minutes
    Recently, we told you about that another cool feature that you have access to in the commercial version of Jelastic, Public IPv4. With a single click you access to a number of cool new capabilities. One of the most important opportunity you get with this feature is the ability to work with your databases remotely and [...]
  • The Jelastic Newsletter – May 23, 2012
    Java 7 adoption, Commercial releases in Europe and Russia and Software stack market share. . . The Jelastic newsletter is a weekly round-up of news, how-to’s and contribution opportunities. Here’s what’s happening this week: Commercial Releases in Europe and Russia As we continue to grow and add partners, we are happy to say that, as of yes […]
  • We are now available commercially in Europe!
    In partnership with dogado, we are now available commercially in Germany The last few weeks have been hectic here at Jelastic! We launched commercially in the US with ServInt; then we did the same in Russian with Rusonyx; and now we have launched commercially in Europe with Germany. Now in Europe Our commercial release with [...]
  • Software stacks market share: May 2012
    Every month we share stats on the usage and popularity of different software stacks within Jelastic PaaS with you. This month it’s even more interesting, because the scope of our stats has grown: we have a new hosting partner in Russia, Rusonyx. So, let’s check out the stats on databases, servers and JVMs for May and analyze the differences betwe […]
  • Geek Project of the Day
    Just in time for the weekend. Here is your geek project of the day. Because sometimes, a regular grill is not enough. We want one. Going to “borrow” a friend’s car and turn it into a grill.

Legal

The posts on this blog are provided “as is” with no warranties and confer no rights. The opinions expressed on this site are mine and mine alone, and do not necessarily represent those of my former employer - Quest Software, or my current employer - Jelastic or anyone else for that matter. All trademarks acknowledged.

© 2007-2012 Dmitry Sotnikov

Pages

 

May 2011
M T W T F S S
« Apr   Jun »
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

Follow

Get every new post delivered to your Inbox.

Join 49 other followers