i guess we have to use AD cmds to pull memberof property. Please refer the below links further.
http://stackoverflow.com/questions/5072996/how-to-get-all-groups-that-a-user-is-a-member-of
http://www.techtalkz.com/microsoft-windows-powershell/417715-get-group-membership-user.html#post1668928
First, install the AD PowerShell module on your Exchange server or wherever you are running the Exchange Management Shell from. You can do this as below:
Install-WindowsFeature RSAT-AD-PowerShell
Then run the below script in an elevated PowerShell window as the CSV output path is the C drive root.
Import-Module ActiveDirectory
$mailboxes = Get-Mailbox -ResultSize Unlimited
$CSV = @()
foreach ($mailbox in $mailboxes)
{
$MemberOfDNs = (Get-ADUser $mailbox.SamAccountName -Properties MemberOf).MemberOf
$MemberOf = @()
foreach($MemberOfDN in $MemberOfDNs)
{
$MemberOf += (Get-ADGroup $MemberOfDN).Name
}
$CSVLine = New-Object System.Object
$CSVLine | Add-Member -Type NoteProperty -Name DisplayName -Value $mailbox.DisplayName
$CSVLine | Add-Member -Type NoteProperty -Name SamAccountName -Value $mailbox.SamAccountName
$CSVLine | Add-Member -Type NoteProperty -Name MemberOf -Value ($MemberOf -join "; ")
$CSV += $CSVLine
}
$CSV | Export-Csv -NoTypeInformation C:\Report.csv
Let me know if that helps you out.
Thanks.
member-of is basically Active Directory related attribute or more related to AD and not Exchange so you would need to use AD related PowerShell cmdlets to fetch the values.
I am sure script Mark gave would be helpful for you...
Hi,
I have a script to share with you. This script will tell you what distribution groups a user is a member of.
$User = read-host -Prompt "Enter Username"
$user_dn = (get-mailbox $user).distinguishedname
"User " + $User + " is a member of the following groups:"
foreach ($group in get-distributiongroup -resultsize unlimited){
if ((get-distributiongroupmember $group.identity | select -expand distinguishedname) -contains $user_dn){$group.name}
}
Best Regards.
Thanks all for your valuable time and support, I've written a script referring you guys per my requirement. Here you go :)
https://gallery.technet.microsoft.com/exchange/Export-Member-of-in-multi-9cf4b315


