Hi all,
I am looking for help, this is what i try to acomplishe
I am loking for disabled users and moving them to Disabled OU, then before i clean up this OU, i want to get and save all data about this users with GroupMembership etc…
this is my code and in some reason it saving just one user,
Hi welcome back to the forum. You are setting the $userproperties variable inside your foreach loop. Remove the assignment inside and put it in front of the foreach.
If you’re not getting output then the variable will be empty. Remove the variable and the export and just confirm you’re getting the output you expect.
Not with the code shown. The code show $usergroups would have two properties: name and groupscope. Perhaps you’re running modified version of what is shown?
For me, it was confusing to call the ForEach loop = $UserProperties because I don’t know if that is per user collection or the whole, so made a slight adjustment.
I believe in this example its ok to have $UserProperties inside the loop.
I did not see original poster mention speed as an issue
You are 100% correct but I do not understand Regex at all to parse out the MemberOf property to a nicely formatted GroupName;GroupName; etc
What? … you don’t need regex at all … what I meant was - you query all users once in advance to get the list of users you want to iterate over and then you query each individual user again inside the loop to get their properties … that’s redundand.
I initially missed the top line of code and was unaware the format of input. Also, just noticed the button that copies ALL code and will do that going forward.
Edit incoming!