Skip to content

Instantly share code, notes, and snippets.

@jkbryan
Last active October 2, 2018 20:05
Show Gist options
  • Save jkbryan/a7e3da5a2a02b01656ba5deba24882ea to your computer and use it in GitHub Desktop.
Save jkbryan/a7e3da5a2a02b01656ba5deba24882ea to your computer and use it in GitHub Desktop.
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