Home > Microsoft, PowerShell, Script, Uncategorized > PowerShell: Get Active Directory groups membership for a user

PowerShell: Get Active Directory groups membership for a user

Hi,

When you have to document every change  Because you’re committed to SOX regulation, you need to extract the data fast

This PowerShell script receive an AD username and export .csv with all Active Directory groups (for Fast Copy&Past).

import-module ActiveDirectory
$name = Read-Host ‘What is the username?’
$csvvv = “.csv”
Get-ADPrincipalGroupMembership $name | select name | Export-CSV ($name+$csvvv)

Save it as .ps1 and run it from the powershell command line,

Advertisements
  1. 22/10/2013 at 13:37

    Can you write a powershell script that outputs all AD groups with its memberships to a csv file?

    • 22/10/2013 at 13:43

      You can first export al the groups to XLS, then load it to Powershell script and loop every row for members

  1. No trackbacks yet.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s