Browsing Category: "Scripting"

Mapping Out Your Active Directory With PowerShell

Scripting December 4th, 2008

After being challenged by Jason on my previous script, I created the Get-ADMapObject script.

Running the script creates three functions:

  • Get-ADMapObject (which takes a string or array of strings of the AD object classes)
  • Get-ADObjectClassName (recurses through your Active Directory and returns the names of the object classes)
  • New-SourceTarget (to get the ADMapObjects into the format that Show-Netmap wants).

Before the script runs, it will check for the dependencies (Doug’s script and the NetMap dll’s) and advise you if there are any missing. I’d love some feedback!

download | copy to clipboard | new post

New Forum Categories on PowerShellCommunity.Org

Associations, Scripting November 24th, 2008

PowerShell interest seems to be flooding all sorts of Microsoft product communities.  Now on, there are forums specifically for SharePoint and SQL Server.  Check them out! 

If you have PowerShell related questions, suggestions, or solutions, please stop in and post!

See you there!

Coming up on the Live Stream (Episode #77)…

Automation, Career, Podcast, Scripting, Servers November 24th, 2008

We will be streaming episode #77 live on on Wednesday, November 26th at 8:30 PM CST.  We will have Brent Ozar, SQL Server Expert for Quest Software, joining us to talk about becoming a DBA (Database Administrator), a sysadmin’s guide to working with DBA’s, and tips for sysadmins who have become “Accidental DBA’s”.  We’ll also have a discussion about DBA’s and scripting, and some news from the PASS (The Professional Assoication for SQL Server) Summit.

 See you there!!

Mapping AD Group Relationships with PowerShell

Scripting November 19th, 2008

A while back, I had restructured my AD groups to match the AGUDLP (Accounts go into Global Groups go into Universal Groups go into DomainLocal Groups where they are applied as Permission) best practice. 

Now, I’m working to align my domain groups with the permissions structure in other applications, so I can create some scripts to automate people changing roles, gaining new responsibilities, and other functions.

I used the Show-NetMap script from Doug Finke, which uses a Microsoft Research project called NetMap, to map out the nested groups in my Active Directory. 

I’d love any feedback or suggestions for using this script.

  1. # Author: Steven Murawski

  2. # This script requires the Show-NetMap script from Doug Finke and the NetMap files

  3. # These can be found at

  4. #

  5. # Also required are the Quest AD Cmdlets.

  6. #requires -pssnapin Quest.ActiveRoles.ADManagement

  7. param([string]$SearchRoot= ‘yourdomain.local/usersOU’)

  8. Function New-SourceTarget ($s,$t) {

  9.         New-Object PSObject |

  10.                 Add-Member -pass noteproperty source $s |

  11.                 Add-Member -pass noteproperty target $t

  12. }

  13. $groups = Get-QADGroup -GroupType Security -SearchRoot $SearchRoot

  14. [string[]]$GroupNames = $groups | foreach {$}

  15. $sources = @()

  16. foreach ($group in $groups)

  17. {

  18.         $name = $

  19.         foreach ($member in $group.members)

  20.         {

  21.                 $SubGroupName = $member -replace ‘^CN=(.+?),OU=.*’, ‘$1’

  22.                 if ($GroupNames -contains $SubGroupName)

  23.                 {

  24.                         $sources += New-SourceTarget $SubGroupName $name

  25.                 }

  26.         }


  28. }

  29. . c:\scripts\powershell\Show-NetMap

  30. $sources | Show-NetMap

downloadThis Script brought to you by PoshCode

PowerShell Community Survey

Scripting November 9th, 2008

Upcoming PowerShell Virtual User Group

Scripting November 3rd, 2008

There is a PowerShell Virtual User Group meeting coming up.  If you haven’t checked one out before, Marco Shaw has set up a PowerShell Virtual User Group, which is hosted online via a Live Meeting.  He normally has a couple of speakers who cover various PowerShell related topics.

The next meeting is scheduled for November 13th at 12 PM EST.

Speakers include Nathan Winter (an Exchange MVP), Joel "Jaykul" Bennet, and there will be a representative from Idera to talk about PowerShell Plus Professional.

More information about the meeting can be found here.

Adding Custom Properties To PowerShell Objects Just Got Easier

Scripting September 7th, 2008

Jeffrey Snover just blogged about working around the Add-Member syntax by extending the System.Object type (which all types inherit from) with a script property called PSAddMember(), which allows you to add NoteProperties (the most common addition to objects) more easily ands supports other scenarios too.


Check it out here.

Interested in PowerShell?

Associations, Career, Scripting September 3rd, 2008

I’ll be providing an introduction to PowerShell at the September LOPSA-Madison meeting (September 11th, at 7:00 PM – room open at 6:30).  If you live in the Milwaukee/Madison, Wisconsin area, come on out.  The LOPSA-Madison chapter has a lot of smart people, interesting discussion, and good networking opportunities.

If you are not in the Southeastern Wisconsin, check out to see if there is a local chapter in your area.  Get Involved!

(There are some door prizes, provided by the sponsors of

Analyze-Packet Reloaded

Scripting August 14th, 2008

Jeffrey Hicks responded to my comments about his Analyze-Packet PowerShell script and took them as a challenge.  Well, he rose to the challenge and sent me a copy of his re-worked scripts and asked for my opinion (he’s the scripting guru, not me, but hey, I’m always willing to shoot my mouth off).

I really liked the way he modified Analyze-Packet to output an analysis object; but, since he asked for my opinion, I thought I would go through it and see what I might do differently.  The biggest thing that jumped out at me was that there were two sections of nearly identical code for name resolution, which begged to be pulled out into a function.  The only other suggestion I had was adding a switch parameter to turn off the name resolution, which can slow down the processing of the script on a large packet capture, where I’ve run into problems before.  (Actually, I had the switch parameter to turn on name resolution, but in the final product, Jeff changed it to be the reverse.  Good call.)  When I’m using other products (read Wireshark), I turn off name resolution as it removes some of the overhead and the distraction of names.

Nice work Jeff.. Check out his blog post here, as he discusses some of the changes that were needed to get both Get-Packet and Analyze-Packet to this point, as well as having the scripts available for download.

Compare Your Twitter Friends and Followers!

Scripting August 2nd, 2008

I saw a post on Twitter asking if there are any applications to check to see if there are any Twitterers who were following you, but that you were not following. So I though that this would be a good PowerShell task.The code is available here