none
Form a query for groups based on Expiration time attribute RRS feed

  • Question

  • Hi All,

    I want to form a PowerShell query to fetch all the groups from FIM expiring on a particular date. Is it possible? I want to ignore the year and consider only month and date as this will be part of task scheduler and will be running on a monthly basis.

    Currently the groups in FIM seem to have expiration time in the format mm/dd/yyyy 00:00:00 AM/PM.

    I am guessing querying groups based on expiration time is not as simple as I thought. I have gone through the blog below as well but still I am not able to form the query for my requirement.

    http://blogs.msdn.com/b/syamp/archive/2011/03/13/fim-2010-xpath-how-to-check-null-value-on-a-datetime-attribute.aspx

    Any suggestions?

    Regards,


    Veena

    Monday, September 28, 2015 1:58 PM

All replies

  • You could try something like this:

    $output = @();
    [int]$tMonth = 11;
    [int]$tDay = 11;
    $results = Export-FIMConfig -CustomConfig "/Group" -Uri "http://localhost:5725" -OnlyBaseResources
    foreach ($result in $results)
    {
    	[DateTime]$timeVal = (($result.ResourceManagementObject.ResourceManagementAttributes | Where-Object {$_.AttributeName -eq "ExpirationTime"}).Value);
    	If ($timeVal -ne $null)
    	{
    		If (($timeVal.Month -eq $tMonth) -and ($timeVal.Day -eq $tDay))
    		{
    			$output += $result;
    		}
    	}
    }
    
    return $output;


    • Edited by mgercevich Thursday, October 1, 2015 8:23 PM
    Thursday, October 1, 2015 8:21 PM
  • As mgercevich shows in the script already posted, you're going to have to retrieve all groups and then loop through them - there's no way to construct an xpat filter based on a partial dat. If you have a lot of groups, and a limited range of years, then the other way to do it is loop through the years, constructing the exact date string for that year and using that in the query.

    http://www.wapshere.com/missmiis

    Thursday, October 1, 2015 8:35 PM