$AllUSers = get-aduser -filter {SamAccountName -like “z*” -and Enabled -eq $true } -Properties Memberof,EmployeeNumber -Server <Domain name> | ?{$PSItem.DistinguishedName -notmatch “OU=Service Accounts”}
$results = new-object System.Collections.ArrayList
foreach($user in $AllSers){
$grps = $user.MemberOf
$v = New-Object System.Collections.ArrayList
foreach($grp in $grps){
$Gobj = Get-ADGroup $grp -Server <Servername:3268> -Properties GroupCategory,GroupScope,Name | select @{l=”GroupName”;e={(($PSItem.DistinguishedName -split “,DC=”)[1])+”\”+$PSItem.SamAccountName}},GroupCategory,GroupScope
$l = $Gobj.GroupName+”,”+ $Gobj.GroupScope +”,”+ $Gobj.GroupCategory
$v.Add($l)
}
$o = [pscustomobject]@{
SamAccountName = $user.SamAccountName
#ProdEmail = $user.EmployeeNumber
Name = $user.GivenName + ” ” +$user.Surname
DevUPN = $user.UserPrincipalName
‘Groups(Name,Scope,Category)’ = $v -join “;”
“Memberof(RawData)” = $user.MemberOf -join “;”
}
$results.Add($o)
}
$results | export-csv C:\Temp\User_Groups.csv -NoTypeInformation
lyzl3h
7xdnit
ny5n7t
0b02py
adylj9
Outstanding post, I conceive blog owners should acquire a lot from this web blog its real user genial.
ptfo03
Very efficiently written article. It will be supportive to anybody who usess it, as well as yours truly :). Keep doing what you are doing – can’r wait to read more posts.
gqvaox
I intended to post you that very small note in order to give many thanks as before over the remarkable methods you’ve contributed on this page. It is quite remarkably open-handed with you to supply unreservedly exactly what a number of people could have sold as an e book to help with making some dough for their own end, specifically given that you might have tried it if you decided. The points in addition served to become a great way to fully grasp that some people have the same zeal similar to my personal own to know the truth much more on the topic of this matter. I’m certain there are lots of more fun periods ahead for people who find out your blog.
The next time I read a blog, I hope that it doesnt disappoint me as much as this one. I mean, I know it was my choice to read, but I actually thought youd have something interesting to say. All I hear is a bunch of whining about something that you could fix if you werent too busy looking for attention.
l055tr
pkn6zs
yad2jr
imq0jk