Export (0) Print
Expand All

EnableAllMPRs

Updated: May 27, 2010

Applies To: Forefront Identity Manager 2010

This is an example of a Windows PowerShell function that enables all management policy rules. For more information, see FIM Windows PowerShell Cmdlet Examples.

EnableAllMPRs Function

This example function queries the Forefront Identity Manager (FIM) Service database for all management policy rule (MPR) resources that have been disabled. For each MPR that is disabled, the ModifyImportObject function is used to create an ImportObject object that represents enabling the MPR (changing the "Disabled" property of the MPR to false). The Import-FIMConfig cmdlet is used to submit the changes to the FIM Service database.

function EnableAllMPRs
{
    PARAM($Uri = $DefaultUri)
    END
    {
        $AllMPRs = QueryResource -Filter "/ManagementPolicyRule[Disabled='true']" -Uri $Uri
        $ImportObjects = $null
        foreach($mpr in $AllMPRs)
        {
            $ModifyImportObject = ModifyImportObject -TargetIdentifier $mpr.ResourceManagementObject.ObjectIdentifier -ObjectType "ManagementPolicyRule"
            SetSingleValue $ModifyImportObject "Disabled" "false"
            if($ImportObjects -eq $null)
            {
                $ImportObjects = (,$ModifyImportObject)
            }
            else
            {
                $ImportObjects += $ModifyImportObject
            }
            
        }
        if($ImportObjects -ne $null)
        {
            $ImportObjects | Import-FIMConfig -Uri $Uri
        }
    }
}

Remarks

The Filter operator that is passed to the QueryResource function is an XPath filter. For example XPath filters, see XPath Filter Dialect Examples.

See Also

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft