EnableAllMPRs

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

Reference

Import-FIMConfig

Concepts

FIM Windows PowerShell Cmdlet Examples
SetSingleValue
CreateImportObject
ResolveObject