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

*

misoprostol online pharmacy

cytotec order on line

cytotec without prescriptions in usa

no prescription generic cytotec

indian cytotec

cytotec purchase overnight delivery

generic cytotec without prescription

no prescription cytotec

cytotec sale no prescription

where to purchase cytotec oral cheap

cytotec order on line

200 mg cytotec

buy cytotec online with no perscription

where can i buy cytotec without a prescription

order cytotec overnight

buy cytotec without a percsription

buy misoprostol australia

100 mg cytotec

cytotec no rx

cytotec online purchase

cytotec for sale

cytotec generic

cytotec oral tablet no prescription discount

how to get cytotec

cytotec online cheap

buy misoprostol cheap without perscription

buying cytotec online

buy cytotec 200mg

order cytotec online consultation

cytotec oral tablet no prescription discount

cheap prices on cytotec

non prescription cytotec

how to by cytotec online

online pharmacy no prescription cytotec

do you need a prescription for cytotec in mexico

how to get cytotec online no prescription in 100 days

Where can i buy some cytotec online only using cash or money orders

cytotec no prescription needed 200mg

overnight shipping on generic cytotec

buy cytotec online no prescription

cytotec precio

order cytotec without rx

buy cytotec next day delivery

order cytotec no prescription

generic cytotec no prescription

cytotec generic

generic cytotec online no prescription

cytotec order

real cytotec without prescription

cytotec buy online

order cytotec online overnight shipping

cytotec buy online no prescription

cytotec online order

canada cytotec

order generic cytotec online no prescription

online pharmacy cytotec