MIM – Finding users with certain changed attributes last 24 hours

This post contains a quick example on how to find users with certain attributes update the last 24 hours. The script uses the Lithnet PowerShell Module, which can be install using Install-Module LithnetRMA.

# Find all requests for person objects last 24 hours
$Requests = Search-Resources "/Request[Target = /Person and RequestStatus = 'Completed' and CreatedTime > op:subtract-dayTimeDuration-from-dateTime(fn:current-dateTime(), xs:dayTimeDuration('P1D'))]" -AttributesToGet RequestParameter, Target

# Define attributes
$attributes = @("Email";"AccountName")

# Filter out relevant requests
$RelevantRequests = $Requests | Where RequestParameter | Where {
    # Write-Verbose $_.objectid.value -verbose
    $_.RequestParameter | Where {
        $RequestParameter = [xml] $_
        $RequestParameter.RequestParameter | ? PropertyName -in $attributes

# Filter out each relevant change (ObjectID and ChangedAttribute)
$RelevantChanges = $RelevantRequests | Foreach {
    $Target = $_.Target
    $_.RequestParameter | Foreach {
        $RequestParameter = [xml] $_
        foreach($attribute in $attributes) {
            $RequestParameter.RequestParameter | ? PropertyName -eq $attribute | Foreach {[PSCustomObject]@{ObjectID = $Target.Value; ChangedAttribute = $attribute}}

$RelevantChanges | Out-GridView

2 thoughts on “MIM – Finding users with certain changed attributes last 24 hours

  1. Hello Marius, I came across this script while looking for a way to pull Requests in MIM through LithNetRMA. I appreciate the sample and have modified the Search-Resources part to only retrieve RequestStatus = ‘PostProcessingError’. This is where I get stuck as it does filter out only PostProcessingErrors however I want to further filter for requests that have postprocessingerrors with specific failure text.

    The issue I seem to face is that the XML data in RequestStatusDetail is not formated the same as your RequestParameter data. There are no tags and since this is my first time working with powershell and xml I’m getting no results. Any tips or relevant information you can pass along?


    1. Good question, though I am really unsure if I am able to help you out. I no longer have any MIM servers available to test anything on πŸ™‚

      You need to start looking at the objects returned from your query, by doing this:

      $MyReturnArray | Select -First 1 | Get-Member

      This will show you different attributes and methods available, and you should be able to further check the members by addressing a single array index $MyReturnArray.SomePropertyFoundByGetMember. This way you can filter things like $MyReturnArray | Where SomeProperty -like “*my text*”.

      The filter is client side (meaning not in the MIM service, but instead it gets all objects and filters in PowerShell), but that might not be an issue for you πŸ™‚

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s