Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Export users of multiple groups from import-csv or get-conent

$
0
0
Hi

I am running below PS command to get the users details of all users which are in groups.csv file with their attributes.

Import-Csv .\groups.csv | % { Get-ADGroupMember $_.group | Get-ADUser -Properties * | select name,SamAccountName,enabled,title,department,@{l='Manager';e={$_.manager -replace 'CN=(.+?),OU=.+','$1'}}} | Export-Csv users.csv -NoTypeInformation -Encoding UTF8

I have got desired result as well.


But I need to segregate all users to belong their groups which mentioned in group.csv file. Also can i export users of groups in csv files each new sheet with group name?

In other way, 

Is this possible that i have around 200 groups name and i want to export group's users with their attribute (user’s name, SamAccountname, status, title, department and their manager’s name/SamAccoutName) in individual csv file 

Viewing all articles
Browse latest Browse all 21975

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>