Powershell ALL AD Users and their Group Memberships
<p>Looking to write a powershell script that will pull ALL AD users, their group memberships and the groups Description Field.</p>

<p>I have been using two scripts to accomplish this, and just manually manipulating them in excel. Any attempt to combine them has been met with error.</p>

<pre><code> Import-module activedirectory
$ou ="DC=blah,DC=blah"
Get-ADGroup -Filter * -SearchBase $OU  | select -expandproperty name | % {
$group= "$_"
$result += Get-ADGroupMember -identity "$_" | select @{n="Group";e={$group}},name
}



$result | export-csv 'c:\users\membership.csv' -notypeinformation
</code></pre>

<p>And:</p>

<pre><code>    Import-Module ActiveDirectory
$Groups = ForEach ($G in (Get-ADGroup -Filter * ))
{

$UN = Get-ADGroup $G -Properties Description | select name, description


New-Object PSObject -Property @{
Desc=$UN.description
Name=$UN.name
}

}

$Groups | Export-CSV C:\users\GroupDesc.csv -notypeinformation
</code></pre>