So if you have a large number of objects to update in FIMService it could be complicated..
Lithnet FIM/MIM Powershell Module makes it so much simpler..
Below is a script I used to say update all accounts which have “accountType” = oldaccounts and set “accountBlocked” to true (my custom schema).
Some explanations
- I have set PageSize = 100 which means if you are returning more than that number process only 100 at a time..
- I have set “-AttributesToGet” which gives me only the attribute what I want
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
$objs = Search-ResourcesPaged -XPath "/Person[(accountType = 'oldaccounts')]" -AttributesToGet accountBlocked $objs.PageSize = 100 $i = 0 while ($objs.HasMoreItems) { $results = $objs.GetNextPage(); foreach ($user in $results) { $user.accountBlocked = $true $i++ } Save-Resource $results Write-Host "Saved $i of " $objs.TotalCount } |
See how easy is that? You can do multiple operations before save-resource and thus do a bunch of changes to say 1000 users and in 10 saves it will be done!!!
PS: As you can see its simple for demonstration and not doing any error handling etc..
0 Comments