Skip to content

Breaking down the size of a FIM Service query with PowerShell

When trying to perform bulk operations against objects in FIM from PowerShell you can run into some pretty slow and heavy going queries. This little snippet shows how you can loop through each letter of the alphabet as a way to reduce the size of the batch of objects you deal with in one go.

$i = 65
do
{
    $c = [char]$i

    $filter = "/Person[starts-with(DisplayName,'{0}')]" -f $c
    $objs = export-fimconfig -CustomConfig $filter -OnlyBaseResources

    foreach ($obj in $objs)
    {
        whatever you need to do
    }

    $i += 1

} while ($i -lt 91)

{ 2 } Comments

  1. Joe Leibowitz | March 8, 2013 at 6:43 pm | Permalink

    Hi Carol,

    The code below uses your ideas but goes three levels deep to start with, e.g., ‘Aba’ rather than ‘A’. So that even in a very large environment, results begin to show up early:

    $i = 65
    do
    {
        $c = [char]$i
        $j = 65
        do
        {
        	$c2 = [char]$j
            $k = 65
                do
                {
                    $c3 = [char]$k
        	        $first_three = $c + $c2 + $c3
                    $first_three_display = $c.ToString().ToUpper() + $c2.ToString().ToLower() +
                        $c3.ToString().ToLower()
                    write-host $first_three.ToString().ToLower()
                    Write-host $first_three_display
        	        $filter = "/Person[starts-with(AccountName,'{0}')]" -f $first_three.ToString().ToLower()
        	        #$filter = "/Person[starts-with(DisplayName,'{0}')]" -f $first_three_display
    
                    $objs = export-fimconfig -uri $URI -CustomConfig $filter -OnlyBaseResources
    
        	        foreach ($obj in $objs)
        	        {
                        #whatever you need to do
                        for($u = 0; $u -lt 10; $u +=1)
                        {
                        write-host 
                          $obj.ResourceManagementObject.ResourceManagementAttributes[$u].AttributeName + ': ' +
                          $obj.ResourceManagementObject.ResourceManagementAttributes[$u].Value
        	            }
                        write-host "`r`n`r`n"
                    }
         $k +=1
                 } while ($k -lt 91)
    
         $j += 1
    
        } while ($j -lt 91)
    
         $i += 1
    
    } while ($i -lt 91)
  2. Carol | March 8, 2013 at 8:49 pm | Permalink

    Awesome! Thanks for sharing.

Post a Comment

Your email is never published nor shared. Required fields are marked *

Spam comments will be blocked by Akismet

*

Endep online order order buy Endep online purchase Endep online without script buy generic Endep from india buy in Endep uk where to buy Endep without a prescription Endep from canada buy 10 mg Aricept generic Aricept cost order Nizoral no visa Nizoral 200 mg buy cheap Nizoral line Nizoral on line best finpecia online pill Requip Requip free Requip uk Amitriptyline generic buy generic Amitriptyline from india where buy Lisinopril purchasing finpecia with overnight delivery Nizoral online buy saturday delivery buy Nizoral in mo finpecia online how to buy Cytotec online without a rx order Aricept pharmacy buy Aricept with no prescription buy Amitriptyline no perscription cod Online us Requip how to buy Amitriptyline without a prescription buy line Amitriptyline buy Amitriptyline money buy purchase Accutane 40 mg on line no rx Accutane 40 mg sale order 40 mg Accutane online next day delivery 40 mg Accutane online buy Lisinopril pay cod Lisinopril overnight cod buy lisinopril without prescription buy lisinopril purchase Premarin cod next day delivery where buy Premarin buy Premarin online free fedex delivery Premarin cheapest place to buy Metformin purchase Metformin online generic 20mg prednisone online finpecia online overnight buy finpecia cheap buy Metformin toronto Metformin prescription buy Metformin where metformin purchased online without prescription buy metformin online cod purchase metformin money purchase order Metformin usa buy metformin cash on delivery buy online rx finpecia without fedex finpecia overnight without a prescription buy Metformin discount can i order finpecia onlinebuy finpecia cheap prednisone prescription cost Metformin canadian pharmacy buy cheap generic Metformin online lisinopril buy lisinopril