Monday, 17 September 2012

How to pull the report to only 500 group ids even if your organisation is having more than 10000 groups?

For example,  you are having more than 2000 groups in your organisation. Now you are in a situation to get the details of owners name of 500 groups only. How you will do?

We can use Get-content to get the data from the text file with the path name mentioned and do the pipeline to the command like below

[PS] C:\Users\sankar\desktop>$list = Get-Content .\groupid.txt | ?{$_ -ne ""} |%{$_.Trim()}
[PS] C:\Users\sankar\desktop>$list.Count
[PS] C:\Users\sankar\desktop>$list | % {Get-DistributionGroup -Identity $_ -ResultSize Unlimited | Select-
Object Name,@{L="ManagedBy";E={$_.ManagedBy}}} | Export-Csv -NoTypeInformation grouplistfromtext.csv