Archive for December, 2009

Get me all groups I manage

Finding all AD groups someone owns is as easy as:

Get-QADGroup -ManagedBy 'Dmitry Sotnikov'

(Obviously put your name, sAMAccountName, DN, email address or another identifier instead of mine. πŸ˜‰ )

This is one of the nice little features added in QAD cmdlets 1.3.

One interesting modification of this cmdlet is to look for all groups owned by your reports:

Get-QADGroup -ManagedBy (Get-QADUser -Manager 'Dmitry Sotnikov')

Or with some output:

Get-QADGroup -ManagedBy (Get-QADUser -Manager 'Dmitry Sotnikov') | Format-Table Name, ManagedBy

Now you can see which groups maybe you should no longer manage, or find nice unused groups for some safe experiments. πŸ˜‰

Advertisements

Adding list of users to group

Say, you get an email asking to add a bunch of members to a distribution list you manage. What is the easiest way to do this? Going to Outlook, making 5 clicks to get to the dialog box, and then manually adding each user from the address book picker is definitely not fun. However, PowerShell definitely is.

I’ve seen people submitting lists of members to add in a couple of ways: separated by commas (or semicolons) or each on a separate line. Both would work fine – the only difference is how you would tell PowerShell to split this string into actual members’ names.

Let’s start with a comma-separated list. Like this:

Hey Dmitry,

Could you please add Kirk Munro, Darin Pendergraft, Oleg Shevnin to the PowerGUI DL?

Thanks!

All you need to do, is copy the part of the email with the names, use PowerShell -split operator to break it by comma characters, and pipe the result into Add-QADGroupMember:

'Kirk Munro, Darin Pendergraft, Oleg Shevnin' -split "," | Add-QADGroupMember PowerGUI

That is it!

Line by line option is not much different – you just have to split by newline character ("`n") instead of comma:

'Kirk Munro
Darin Pendergraft
Oleg Shevnin' -split "`n" | Add-QADGroupMember PowerGUI

And by the way, email addresses instead of user names are totally fine too:

'user1@domain.my, user2@domain.my' -split "," | Add-QADGroupMember PowerGUI

One of those cases when command line is so much easier than UI. πŸ™‚

Hacking PowerGUI

Let’s talk about a few community efforts taking PowerGUI extensibility to the next level.

As a background, PowerGUI Admin Console was designed with extensibility in mind and has a notion of PowerPacks. Basically, the console is simply displaying and executing the PowerShell code supplied in the PowerPack add-ons you load. Kirk has created a great PowerPack step-by-step tutorial/reference, and shot a ten-minute screencast on that topic.

However, sometimes the native PowerPack management functionality we provide is not sufficient or we are not documenting what you can do fast enough. If you feel like that, I would highly recommend that you:

If you want to get the most out of your custom PowerGUI admin consoles – these efforts are well worth checking out and actually joining! PowerGUI is so successful because it is a community effort and you could help take it to the next level! πŸ˜‰

New PowerGUI Overview Video

New to PowerGUI admin console or script editor and debugger? Or just not sure whether you are up to speed with all the major functionality the product has?

Watch this video overview of all the key functionality the product has which Darin has just posted (full screen and HD recommended):

It is about 20 and takes you from basics to features such as graphical admin console, powerpacks, filtering, reporting, script editor, debugging, code snippets and online search. If you want to also see the table of content and be able to jump between the topic – use the version we posted here.

PowerGUI Survey

When do we stop supporting PowerShell 1.0 in newer releases of PowerGUI and switch to PowerShell 2.0 only? You can affect this by responding to the poll Darin put on the PowerGUI User Discussions forum:

The poll is in the right-hand column of the PowerGUI Discussion Forum

Please take a few seconds by answering one single question of the poll: when do you expect to have your administrative workstation upgraded to PowerShell 2.0. You need to log into PowerGUI.org to vote.

The poll is available at the right-hand column of the PowerGUI User Discussions forum.

You can also post your comments here or in this discussion thread.

Thank you in advance!

Winter PowerGUI Wallpaper is here

PowerGUI Wallpaper for Winter 2009/2010And it is the most beautiful one we have ever had! Just pick the size you need, apply it to your desktop and enjoy the upcoming holiday season:

1024×768,
1280×800,
1280×960,
1280×1024,
1440×900,
1600×1200,
1920×1200.

Our downloads page also has links to the Christmas/New Year wallpaper we had last year, and for our friends in the Southern Hemisphere there a couple summer options! πŸ˜‰

Restructuring AD groups

Creating a subgroup and removing duplicate accounts from parent group is easy. I have just done this to one of the groups I manage (dev manager of one of the teams created a group for the team so I could include the group rather than individual members) and thought I would share the one-liner with you:

Compare-Object (Get-QADGroupMember MainGroup) (Get-QADGroupMember SubGroup) -ExcludeDifferent -IncludeEqual | Select -Expand InputObject | Remove-QADGroupMember MainGroup -WhatIf

Obviously, put your group names in there, and remove the -WhatIf if you want this command to actually change group membership.

The oneliner is pretty much self-explanatory:

  1. I first compare group membership of the two groups (using Compare-Object),
  2. Exclude the objects which are different and only retrieve the ones which are the same,
  3. Then I ask PowerShell to give me the actual objects (Select -Expand InputObject) – otherwise Compare-Object gives its wrappers with direction indicators and we do not need them here, and then
  4. Pipe these into the Remove-QADGroupMember command.

Very simple and saved me a few minutes today! Which I then used to write this blog post. πŸ˜‰


My Recent Tweets

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 employer - WSO2 or anyone else for that matter. All trademarks acknowledged.

Β© 2007-2014 Dmitry Sotnikov

December 2009
M T W T F S S
« Nov   Jan »
 123456
78910111213
14151617181920
21222324252627
28293031  
Advertisements

%d bloggers like this: