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
547
[PS] C:\Users\sankar\desktop>$list | % {Get-DistributionGroup -Identity $_ -ResultSize Unlimited | Select-
Object Name,@{L="ManagedBy";E={$_.ManagedBy}}} | Export-Csv -NoTypeInformation grouplistfromtext.csv
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
547
[PS] C:\Users\sankar\desktop>$list | % {Get-DistributionGroup -Identity $_ -ResultSize Unlimited | Select-
Object Name,@{L="ManagedBy";E={$_.ManagedBy}}} | Export-Csv -NoTypeInformation grouplistfromtext.csv
No comments:
Post a Comment