GetResource

Applies To: Forefront Identity Manager 2010

This is an example of a Windows PowerShell function that queries the Forefront Identity Manager (FIM) Service database for a resource based on the ObjectID. For more information, see FIM Windows PowerShell Cmdlet Examples.

GetResource Function

This is an example of a Windows PowerShell function that uses the Import-FIMConfig cmdlet to query the FIM Service database for a resource based on the ObjectID. If the query is successful, the function returns a reference to the resource. If no such object is found, the function writes a message to the Windows PowerShell host.

$DefaultUri = "https://localhost:5725"

function GetResource
{
    PARAM($ObjectIdentifier, $Uri = $DefaultUri)
    END
    {
        $object = Export-FIMConfig -CustomConfig [System.String]::Format("*[ObjectID='{0}']", $ObjectIdentifier) -Uri $Uri
        if($object -eq $null)
        {
            Write-Host "Object was not found."
        }
        else
        {
            $object
        }
    }
}

Remarks

This function is a more limited example of the QueryResource function, which can return all resources that match a query.

See Also

Reference

Import-FIMConfig

Concepts

FIM Windows PowerShell Cmdlet Examples