FIM Portal Powershell Get users using wildcard characters

Hi

Noob at FIM and powershell

If we want to get all users in portal with DisplayName starting with A.. how do we do that?


$PeopleStartingWithA = export-fimconfig `
    onlyBaseResources `
    -customconfig "/Person[DisplayName = 'A*']"

This does not work.. So how can we do this?

Just trying to create a powershell to get all those users and delete them..

Thanks


May 25th, 2014 11:58pm

Please use the following:
/Person[starts-with(DisplayName, 'A')]
Free Windows Admin Tool Kit Click here and download it now
May 26th, 2014 1:49am

Thanks.. Isin't that a boolean return and not all users?

I get the error

export-fimconfig : Failure on making enumeration web service call. 
Filter = /Person[starts-with(DisplayName, 'A'] 
Error= Microsoft.ResourceManagement.WebServices.Faults.ServiceFaultException: cannot filter as requested
   at Microsoft.ResourceManagement.WebServices.Client.ResourceTemplate.EnumerateResources(SearchParameters parameters, 
ClientOptionsHelper clientOptionsHelper)
   at Microsoft.ResourceManagement.WebServices.ResourceManager.MoveNext()
   at Microsoft.ResourceManagement.Automation.ExportConfig.EndProcessing() 
At XXXXXXXXXXXXX\Delete.ps1:6 char:30
+ $PeopleStartingWithA = export-fimconfig `
+                              ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Export-FIMConfig], InvalidOperationException
    + FullyQualifiedErrorId : ExportConfig,Microsoft.ResourceManagement.Automation.ExportConfig

Code

Add-PSSnapin fimautomation

$PeopleStartingWithA = export-fimconfig `
    onlyBaseResources `
    -customconfig "/Person[starts-with(DisplayName, 'A']"

Write-Host $PeopleStartingWithA 

May 26th, 2014 1:53am

I don't know why such filter is not working, but you can try the following:

Create a Set named !_TST with the following filter:

After creating it, please try the following:

Add-PSSnapin fimautomation

$PeopleStartingWithA = export-fimconfig `
    onlyBaseResources `
    -customconfig "/Person[ObjectID = /Set[DisplayName = '!_TST']/ComputedMember]"

Write-Host $PeopleStartingWithA 

Free Windows Admin Tool Kit Click here and download it now
May 26th, 2014 3:12am

Thanks.. That is working .. I guess I was missing few ( ) .

Is it faster to call the Set in the powershell or is it faster to call just the code it uses? or just does not matter.. both do the same?

/Person[(starts-with(DisplayName, 'A'))]

We have a scenario to delete 100,000+ users..

May 26th, 2014 9:46pm

I'd say that calling Set members is faster - Set is calculated prior to your query, so you don't ask for "all Person objects, but view only those who starts with A", but only for Set members. So this one should be faster.
Free Windows Admin Tool Kit Click here and download it now
May 27th, 2014 1:30am

So this will work much faster for 100,000+ users?

Add-PSSnapin fimautomation

$AllPeople = export-fimconfig `
    onlyBaseResources `
   -customconfig "/Person[ObjectID = /Set[DisplayName = '!_TEST']/ComputedMember]"

$UsersToDelete = $AllPeople.ResourceManagementObject 

$AllImportObjects = @()
$UsersToDelete | % {
   $importObject = New-Object Microsoft.ResourceManagement.Automation.ObjectModel.ImportObject
       $importObject.ObjectType = 'Person'
       $importObject.TargetObjectIdentifier = $_.ObjectIdentifier
        $importObject.SourceObjectIdentifier = $_.ObjectIdentifier
        $importObject.State = 2 
    $AllImportObjects += $importObject

    }

$AllImportObjects | Import-FIMConfig 
Where !_TEST is
/Person[(starts-with(DisplayName, '%'))]

May 27th, 2014 1:36am

If you would use this as a filter:

/Person[(starts-with(DisplayName, '%'))]

 You are getting all users (or do you have any users with empty display name?), so you can use /Person as a whole filter. But please don't do it this way - you would delete also your admin account and fim ma (Built-in synchronization account).

So in both cases - with and without sets - please filter out those two accounts at least.

Free Windows Admin Tool Kit Click here and download it now
May 27th, 2014 2:33am

Thanks.. That is working .. I guess I was missing few ( ) .

Is it faster to call the Set in the powershell or is it faster to call just the code it uses? or just does not matter.. both do the same?

/Person[(starts-with(DisplayName, 'A'))]

We have a scenario to delete 100,000+ users..

May 27th, 2014 4:41am

Thanks.. That is working .. I guess I was missing few ( ) .

Is it faster to call the Set in the powershell or is it faster to call just the code it uses? or just does not matter.. both do the same?

/Person[(starts-with(DisplayName, 'A'))]

We have a scenario to delete 100,000+ users..

Free Windows Admin Tool Kit Click here and download it now
May 27th, 2014 4:41am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics