Link to home
Start Free TrialLog in
Avatar of Parity123
Parity123Flag for United States of America

asked on

Powershell : Group info

Hello Experts,

I need to output sidHistory values for the group along with ManagedBy. There are multiple SIDHistory Values in some groups, so I need to output all the values for that group. I have the script below, which only outputs 1 SIDHistory Value.

$MyTempGroups =  gc ./groups.txt
$result = @()
foreach($group in $MyTempGroups) {
$x = get-adgroup $group -properties sidhistory, ManagedBy, | select ManagedBy, sidHistory
$result += $x.ManagedBy +  ";"  + $x.sidHistory
}
$result | out-file ./results.txt

Your assistance is appreciated.
Avatar of Qlemo
Qlemo
Flag of Germany image

You should get a single record with a (space separated( list of SIDS already.
But your script doesn't make much sense to me as is. You are concatenating all data, not including the respective group.
What is your actual expected result if using multiple groups and having done more than one domain migration for the group objects? Can you show a short example output?
Avatar of Parity123

ASKER

The output needs to be as follows:

GroupName; ManagedBy; sid1,sid2

Thanks.
SOLUTION
Avatar of Ben Personick (Previously QCubed)
Ben Personick (Previously QCubed)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks