001

002

003

004

005

006

007

008

009

010

011

012

013

014

015

016

017

018

019

020

021

022

023

024

025

026

# How to Use PowerShell Showing number of SETs a User Is a Member Of (FIM Portal)

$User = Read-Host "Enter the user display name"

  

if(@(Get-PSSnapin | ? { $_.Name -eq "FIMAutomation" } ).Count -eq 0)

{

 Add-PSSnapin FIMAutomation; 

} 

  

$Sets = Export-FIMConfig -customConfig '/Set' -Uri "http://localhost This link is external to TechNet Wiki. It will open in a new window. :5725"  -OnlyBaseResources

  

foreach ($Set in $Sets)

{ 

 foreach($i in (($Set.ResourceManagementObject.ResourceManagementAttributes | Where-Object {$_.AttributeName -eq "DisplayName"}).Value) )

  

 {

   $Member = Export-FIMConfig -customConfig "/Person[ObjectID = /Set[DisplayName = '$i']/ComputedMember]" -Uri "http://localhost This link is external to TechNet Wiki. It will open in a new window. :5725"  -OnlyBaseResources

   foreach($Mem in $Member)

   {

      $y=(($Mem.ResourceManagementObject.ResourceManagementAttributes | Where-Object {$_.AttributeName -eq "DisplayName"}).Value)

   if($y -eq $User)

   {

   Write-Host "$i"

   }  

  }

 } 

}


See Also