Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
get-ComputedMember-from-input-file
If(@(Get-PSSnapin | ? { $_.Name -eq "FIMAutomation"}).Count -eq 0)
{
Add-PSSnapin FIMAutomation;
}
#input file name - listing the group display names that I want to query the membership of:
$a=Get-Content "c:\FIMScripts\GroupNames.txt"
ForEach ($i in $a)
{
Write-Host $i
$Group = Export-FIMConfig -customConfig "/Person[ObjectID = /Group[DisplayName = '$i']/ComputedMember]" -Uri "http://localhost:5725" -OnlyBaseResources
foreach($m in $Group)
{
# I wanted the samAccountName returned to the output file - as this is what I'm exporting to the corresponding output file from AD:
$Name = (($m.ResourceManagementObject.ResourceManagementAttributes | Where-Object {$_.AttributeName -eq "AccountName"}).Value)
# List of samAccountNames written to txt file
$Name>>C:\users\$env:USERNAME\desktop\Groups\$i.txt
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.