### Install Lithnet Resource Management PowerShell Module Source: https://docs.lithnet.io/resource-management-powershell/installation/installing-the-module Installs the Lithnet Resource Management module from the PowerShell Gallery. This command requires PowerShellGet to be installed and configured. It fetches and installs the latest version of the module. ```powershell Install-Module LithnetRMA ``` -------------------------------- ### Iterate through result set starting from a specific point using Search-ResourcesPaged Source: https://docs.lithnet.io/resource-management-powershell/usage/cmdlet-reference/search-resourcespaged This PowerShell example illustrates how to start iterating through a result set from a specific index using the Search-ResourcesPaged cmdlet. It sets the initial index using CurrentIndex and then proceeds to fetch and process pages of results. ```powershell $pager = Search-ResourcesPaged -Xpath "/Set"; $pager.PageSize = 10; $pager.CurrentIndex = 50; # Loop through the result set until there are no more results while ($pager.HasMoreItems) { # Get 10 results $resultSet = $pager.GetNextPage(); # Iterate through each result and print the ObjectID foreach($result in $resultSet) { $result.ObjectID } # Repeat until all results have been processed } ``` -------------------------------- ### Create and Populate Object Template with New-Resource Source: https://docs.lithnet.io/resource-management-powershell/usage/cmdlet-reference/new-resource This example demonstrates how to use the New-Resource cmdlet to create a new 'Person' object template. It then populates properties like AccountName, Domain, DisplayName, and JobTitles before saving the object to the FIM service using the Save-Resource cmdlet. This requires the Lithnet Resource Management PowerShell module to be installed. ```powershell # Create a new person object $obj = New-Resource -ObjectType Person $obj.AccountName = "testuser" $obj.Domain = "fim-dev1" $obj.DisplayName = "test user" $obj.JobTitles = @("Test1", "Test2") Save-Resource $obj ``` -------------------------------- ### Resource Query Operators Source: https://docs.lithnet.io/resource-management-powershell/help-and-support/xpath-expression-examples This section details the supported operators for querying resources, including examples for Equals, NotEquals, and IsPresent. ```APIDOC ## Resource Query Operators ### Description This endpoint supports querying resources using a variety of operators. The examples below demonstrate the syntax for common operators. ### Method GET ### Endpoint `/ResourceName[(Operator = 'Value')]` ### Parameters #### Path Parameters - **ResourceName** (string) - Required - The name of the resource type to query. #### Query Parameters - **Operator** (string) - Required - The operator to use for filtering (e.g., Equals, NotEquals, IsPresent). - **Value** (string) - Required - The value to compare against or the presence indicator. #### Request Body Not applicable for GET requests. ### Request Example ``` GET /Person[(Manager = '3ede2d5f-a6db-4795-b07a-827840024940')] GET /Person[(Manager = /Person[(AccountName = 'ryan')])] GET /Person[(not(Manager = '3ede2d5f-a6db-4795-b07a-827840024940'))] GET /Person[(Manager = /*)] GET /Person[(not(Manager = /*))] ``` ### Response #### Success Response (200) - **Resources** (array) - A list of resources matching the query criteria. #### Response Example ```json { "Resources": [ { "ObjectType": "Person", "ObjectID": "a1b2c3d4-e5f6-7890-1234-567890abcdef", "AccountName": "john.doe", "Manager": "3ede2d5f-a6db-4795-b07a-827840024940" } ] } ``` ### Unsupported Operators - GreaterThan - GreaterThanOrEquals - LessThan - LessThanOrEquals - Contains - StartsWith - EndsWith ### Limitations - Querying text attributes is not supported. - Querying binary attributes is not supported. ``` -------------------------------- ### Create and Save New Resource Object Source: https://docs.lithnet.io/resource-management-powershell/usage/cmdlet-reference/save-resource This example illustrates creating a new 'Person' resource object, populating its 'AccountName', 'ExpiryDate', and 'ObjectSID' attributes, and then saving it using Save-Resource. ```powershell # Create a new resource template for the object type 'Person', populate some attributes, and save the new resource $obj = New-Resource -ObjectType Person $obj.AccountName = "newuser" $obj.ExpiryDate = "2020-01-01T00:00:00.000" $obj.ObjectSID = "AQUAAAAAAAUVAAAAFYLkaG79nJrWb05iFzcCAA==" #Base 64 encoded value Save-Resource $obj ``` -------------------------------- ### String Attribute XPath Queries - PowerShell Source: https://docs.lithnet.io/resource-management-powershell/help-and-support/xpath-expression-examples Examples of XPath queries for string attributes, including Equals, NotEquals, IsPresent, IsNotPresent, Contains, StartsWith, and EndsWith operators. These queries are used with Resource Management PowerShell cmdlets. ```PowerShell New-XPathExpression "/Person[(AccountName = 'ryan')]" New-XPathExpression "/Person[(not(AccountName = 'ryan'))]" New-XPathExpression "/Person[(starts-with(AccountName, '%'))]" New-XPathExpression "/Person[(not(starts-with(AccountName, '%')))]" New-XPathExpression "/Person[(contains(DisplayName, 'ryan'))]" New-XPathExpression "/Person[(starts-with(DisplayName, 'ryan'))]" New-XPathExpression "/Person[(ends-with(DisplayName, 'ryan'))]" ``` -------------------------------- ### Lithnet Resource Management: Basic Operations (PowerShell) Source: https://docs.lithnet.io/resource-management-powershell/help-and-support/quick-reference-guide Demonstrates fundamental operations like importing the module, connecting to the service, and performing get, update, save, search, and delete actions on resources. It also shows how to create new resources and handle pending approvals. ```powershell # Import the module Import-Module LithnetRMA; # Connect to the FIM service instance Set-ResourceManagementClient -BaseAddress http://fimsvc:5727; # Get a user by its account name $obj = Get-Resource -ObjectType Person -AttributeName AccountName -AttributeValue ryan; # Write all the attributes of the user to the screen Write-Host $obj; # Set a new value for the JobTitle attribute $obj.JobTitle = "Tester"; # Save the changes to the Resource Management Service Save-Resource $obj # Search for a set Search-Resources -XPath "/Set[DisplayName = 'Administrators']" # Search for a set and return all attributes in the set object type $set = Search-Resources -XPath "/Set[DisplayName = 'Administrators']" -ExpectedObjectClass Set Write-Host $set # Search for a set and return only the computed member and explicit member attributes in the set object type Search-Resources -XPath "/Set[DisplayName = 'Administrators']" -AttributesToGet @("ComputedMember", "ExplicitMember") # Delete a resource by a known ID Remove-Resource 'cacfb5f3-4924-4b56-89ee-b6b0de3e36d5' # Remove a resource by its reference using the pipeline Get-Resource Person AccountName testuser | Remove-Resource # Create a new user $newObject = New-Resource -ObjectType Person $newObject.AccountName = "testuser"; Save-Resource $newObject # Get pending approvals $pendingApprovals = Get-ApprovalRequest -Status Pending # Approve pending approvals Get-ApprovalRequest -Status Pending | Set-PendingApprovalRequest -Decision Approved -Reason "I said so!" # Reject pending approvals Get-ApprovalRequest -Status Pending | Set-PendingApprovalRequest -Decision Rejected -Reason "I said so!" ``` -------------------------------- ### Save Single Resource Object Source: https://docs.lithnet.io/resource-management-powershell/usage/cmdlet-reference/save-resource This example demonstrates how to retrieve a single resource object using Get-Resource, modify its DisplayName attribute, and then save the changes using Save-Resource. ```powershell $obj = Get-Resource Person AccountName testuser $obj.DisplayName = "Test User2" Save-Resource $obj ``` -------------------------------- ### Load Lithnet Resource Management PowerShell Module Source: https://docs.lithnet.io/resource-management-powershell/installation/installing-the-module Loads the Lithnet Resource Management module into the current PowerShell session, making its cmdlets available for use. This can be done using the full cmdlet name or its alias. ```powershell Import-Module LithnetRMA ``` ```powershell ipmo LithnetRMA ``` -------------------------------- ### Manage Multivalued Attributes using PowerShell Source: https://docs.lithnet.io/resource-management-powershell/help-and-support/working-with-different-data-and-attribute-types Provides examples for managing multivalued attributes such as 'jobTitles' in PowerShell. This includes setting multiple values at once, adding a new value, and removing an existing value. ```powershell # Setting a multivalued attribute $obj = Get-Resource -ObjectType Person -AttributeName AccountName -AttributeValue testuser $obj.jobTitles = @("Manager", "Engineer") Save-Resource $obj # Adding a value to a multivalued attribute $obj = Get-Resource -ObjectType Person -AttributeName AccountName -AttributeValue testuser $obj.jobTitles.Add("Developer"); Save-Resource $obj # Removing a value from a multivalued attribute $obj = Get-Resource -ObjectType Person -AttributeName AccountName -AttributeValue testuser $obj.jobTitles.Remove("Developer"); Save-Resource $obj ``` -------------------------------- ### XML Variable Definition Example Source: https://docs.lithnet.io/resource-management-powershell/configuration/variables-file/variables-element/variable-element This XML snippet demonstrates how to define custom user variables using the element. It shows examples of using environment variables and fixed string values. ```xml ``` -------------------------------- ### XML Example of AnchorAttributes Element Source: https://docs.lithnet.io/resource-management-powershell/configuration/operations-element/anchorattributes-element This XML snippet demonstrates the structure of the AnchorAttributes element, which contains child AnchorAttribute elements to specify attributes for resource existence checks. ```xml DisplayName ``` -------------------------------- ### Integer Attribute XPath Queries - PowerShell Source: https://docs.lithnet.io/resource-management-powershell/help-and-support/xpath-expression-examples Examples of XPath queries for integer attributes, including Equals, NotEquals, GreaterThan, GreaterThanOrEquals, LessThan, LessThanOrEquals, IsPresent, and IsNotPresent operators. These queries are used with Resource Management PowerShell cmdlets. ```PowerShell New-XPathExpression "/Person[(unixGid = 44)]" New-XPathExpression "/Person[(not(unixGid = 44))]" New-XPathExpression "/Person[(unixGid > 44)]" New-XPathExpression "/Person[(unixGid >= 44)]" New-XPathExpression "/Person[(unixGid < 44)]" New-XPathExpression "/Person[(unixGid <= 44)]" New-XPathExpression "/Person[(unixGid <= 999999999999999)]" New-XPathExpression "/Person[(not(unixGid <= 999999999999999))]" ``` -------------------------------- ### Approve All Pending Requests via Pipeline in PowerShell Source: https://docs.lithnet.io/resource-management-powershell/usage/cmdlet-reference/set-pendingapprovalrequest This example shows how to approve all pending approval requests efficiently using the PowerShell pipeline. Get-ApprovalRequest filters for 'Pending' status, and the results are piped directly to Set-PendingApprovalRequest with the 'Approved' decision and an optional reason. ```powershell Get-ApprovalRequest -Status Pending | Set-PendingApprovalRequest -Decision Approved -Reason "Make it so!" ``` -------------------------------- ### Boolean Attribute XPath Queries - PowerShell Source: https://docs.lithnet.io/resource-management-powershell/help-and-support/xpath-expression-examples Examples of XPath queries for boolean attributes, including Equals, NotEquals, IsPresent, and IsNotPresent operators. These queries are used with Resource Management PowerShell cmdlets. ```PowerShell New-XPathExpression "/Person[(AccountDisabled = true)]" New-XPathExpression "/Person[(not(AccountDisabled = true))]" New-XPathExpression "/Person[((AccountDisabled = true) or (AccountDisabled = false))]" New-XPathExpression "/Person[(not(((AccountDisabled = true) or (AccountDisabled = false))))]" ``` -------------------------------- ### Get Localized Resource Representation - PowerShell Source: https://docs.lithnet.io/resource-management-powershell/usage/cmdlet-reference/get-resource Fetches a localized representation of a resource's attribute, such as its display name in a specific language. Requires the appropriate language packs to be installed on the FIM/MIM Service. Example uses Italian ('it-IT') for the 'Display Name' attribute. ```powershell # Gets the display name of the "Display Name" attribute, in Italian $obj = Get-Resource -ObjectType AttributeTypeDescription -AttributeName Name -AttributeValue DisplayName -Locale it-IT ``` -------------------------------- ### Build Simple XPath Query with New-XPathExpression (PowerShell) Source: https://docs.lithnet.io/resource-management-powershell/usage/cmdlet-reference/new-xpathquery Shows how to create an XPath query component with New-XPathQuery and then use it with New-XPathExpression to construct a full XPath query for a 'Person' object type. Includes examples using both direct parameter passing and the pipeline. ```powershell $query = New-XPathQuery -AttributeName "AccountName" -Operator Equals -Value "ryan" $expression = New-XPathExpression -ObjectType "Person" -QueryObject $query $expression.ToString() ``` ```powershell $expression = New-XPathQuery -AttributeName "AccountName" -Operator Equals -Value "ryan" | New-XPathExpression -ObjectType "Person" $expression.ToString() ``` -------------------------------- ### DateTime Attribute XPath Queries - PowerShell Source: https://docs.lithnet.io/resource-management-powershell/help-and-support/xpath-expression-examples Examples of XPath queries for DateTime attributes, including Equals, NotEquals, GreaterThan, GreaterThanOrEquals, LessThan, LessThanOrEquals, IsPresent, and IsNotPresent operators. These queries are used with Resource Management PowerShell cmdlets. ```PowerShell New-XPathExpression "/Person[(ExpiryDate = '2015-12-31T00:00:00.000')]" New-XPathExpression "/Person[(not(ExpiryDate = '2015-12-31T00:00:00.000'))]" New-XPathExpression "/Person[(ExpiryDate > '2015-12-31T00:00:00.000')]" New-XPathExpression "/Person[(ExpiryDate >= '2015-12-31T00:00:00.000')]" New-XPathExpression "/Person[(ExpiryDate < '2015-12-31T00:00:00.000')]" New-XPathExpression "/Person[(ExpiryDate <= '2015-12-31T00:00:00.000')]" New-XPathExpression "/Person[(ExpiryDate <= '9999-12-31T23:59:59.997')]" New-XPathExpression "/Person[(not(ExpiryDate <= '9999-12-31T23:59:59.997'))]" ``` -------------------------------- ### Reference ResourceOperation Element (XML) Source: https://docs.lithnet.io/resource-management-powershell/configuration/building-references This example shows how to reference another ResourceOperation element within the same XML file. It uses an AttributeOperation with 'type="xmlref"' to link to a ResourceOperation defined elsewhere, automatically populating the correct Object ID. ```xml DisplayName ___Demo Workflow Definition .\Templates\WFDemo.xml Action false DisplayName ___Demo MPR - Triggers Workflow demoWorkflowDefinition ``` -------------------------------- ### XML Example: ResourceOperations Element Source: https://docs.lithnet.io/resource-management-powershell/configuration/operations-element This XML snippet demonstrates the structure of the element, which encloses individual elements. It serves as a configuration block for defining resource management operations. ```xml ... ... ``` -------------------------------- ### Import Variables using 'import-file' Attribute (XML) Source: https://docs.lithnet.io/resource-management-powershell/configuration/variables-file/variables-element This example shows how to use the 'import-file' attribute within the element. This allows you to consolidate variables into separate files and import them, promoting modularity in your configurations. ```xml ``` -------------------------------- ### Update Localized Resource Value Source: https://docs.lithnet.io/resource-management-powershell/usage/cmdlet-reference/save-resource This example shows how to retrieve a resource object with a specific locale ('it-IT'), update its 'DisplayName' attribute, and save the localized change using Save-Resource with the '-Locale' parameter. ```powershell $obj = Get-Resource AttributeTypeDescription Name DisplayName -Locale it-IT $obj.DisplayName = "Nome visualizzato" Save-Resource $obj -Locale it-IT ``` -------------------------------- ### Get Resource by ObjectType and AttributeValuePairs - PowerShell Source: https://docs.lithnet.io/resource-management-powershell/usage/cmdlet-reference/get-resource Retrieves a single resource by providing a hashtable of attribute and value pairs that uniquely identify the object. This is useful for queries involving multiple unique identifiers, such as 'AccountName' and 'Domain'. ```powershell $obj = Get-Resource -ObjectType Person -AttributeValuePairs @{AccountName = "testuser"; Domain="fim-dev1"} ``` -------------------------------- ### Get Approval Requests with PowerShell Source: https://docs.lithnet.io/resource-management-powershell/usage/cmdlet-reference/get-approvalrequest Retrieves approval requests using the Get-ApprovalRequest cmdlet. It can fetch all requests or filter by status such as Pending, Expired, Rejected, or Approved. This cmdlet is often piped to Set-PendingApprovalRequest to manage decisions. ```powershell # Get all pending approvals $obj = Get-ApprovalRequest -Status Pending # Get all approval requests $obj = Get-ApprovalRequest # Approval all pending requests Get-ApprovalRequest -Status Pending | Set-PendingApprovalRequest -Decision Approved ``` -------------------------------- ### Get Resource by ObjectType, AttributeName, and AttributeValue - PowerShell Source: https://docs.lithnet.io/resource-management-powershell/usage/cmdlet-reference/get-resource Fetches a single resource by specifying its object type, an anchor attribute name, and its corresponding value. This method is useful for retrieving objects based on known properties like 'AccountName'. The cmdlet will throw an exception if multiple objects match. ```powershell $obj = Get-Resource -ObjectType Person -AttributeName AccountName -AttributeValue testuser ``` -------------------------------- ### Example XML Filter Expression Output Source: https://docs.lithnet.io/resource-management-powershell/usage/cmdlet-reference/new-xpathexpression This shows the resulting XML string generated by the PowerShell script when the `-WrapFilterXml` option is used. The output is a well-formed XML element representing the filter criteria. ```xml /Person[(AccountName = 'ryan')] ``` -------------------------------- ### Get Resource by Object ID - PowerShell Source: https://docs.lithnet.io/resource-management-powershell/usage/cmdlet-reference/get-resource Retrieves a single resource from the FIM Service using its unique object ID. This is a direct lookup method. Ensure the provided ID is valid. ```powershell Get-Resource -ID '7fb2b853-24f0-4498-9534-4e10589723c4' ``` -------------------------------- ### Save Multiple Resource Objects in Composite Operation Source: https://docs.lithnet.io/resource-management-powershell/usage/cmdlet-reference/save-resource This example shows how to update the 'Location' attribute for multiple 'Person' objects found in 'Melbourne' and save these changes as a single composite operation using Save-Resource. ```powershell # Update the Location of multiple objects and save them as a single composite operation $objs = Search-Resources "/Person[Location='Melbourne']" -AttributesToGet @("Location") foreach($obj in $objs) { $obj.Location = "Auckland" } Save-Resource $objs ``` -------------------------------- ### Set Reference Attributes using PowerShell Source: https://docs.lithnet.io/resource-management-powershell/help-and-support/working-with-different-data-and-attribute-types Shows how to set reference attributes like 'Manager' in PowerShell. This can be done using a GUID string, another resource object, or a native UniqueValue from another reference attribute. ```powershell # Sets the value of a person's manager attribute to a known ID $obj = Get-Resource -ObjectType Person -AttributeName AccountName -AttributeValue testuser $obj.Manager = '7fb2b853-24f0-4498-9534-4e10589723c4' Save-Resource $obj # Sets the value of a person's manager attribute to that of another object $obj.Manager = GetResource -ObjectType Person -AttributeName AccountName -AttributeValue testuser2 Save-Resource $obj ``` -------------------------------- ### Dereference XML ResourceOperation Attribute (XML) Source: https://docs.lithnet.io/resource-management-powershell/configuration/building-references This example shows how to dereference an XML ResourceOperation and retrieve one of its attributes using a special variable syntax. The format `##xmlref::##` allows dynamic referencing of attribute values from other ResourceOperations. ```xml DisplayName ___Demo Workflow Definition Triggers the "##xmlref:demoWorkflowDefinition:DisplayName##" workflow ``` -------------------------------- ### AttributeOperations XML Configuration Example Source: https://docs.lithnet.io/resource-management-powershell/configuration/operations-element/attributeoperations-element This XML snippet demonstrates the structure of the element, which holds multiple child elements. It is used in Lithnet Resource Management PowerShell configurations to group attribute modification operations. ```xml ``` -------------------------------- ### Get Resource by ObjectType, AttributeName, AttributeValue, and AttributesToGet - PowerShell Source: https://docs.lithnet.io/resource-management-powershell/usage/cmdlet-reference/get-resource Retrieves a specific resource using its object type and anchor attribute, while also limiting the returned properties to a specified list. This optimizes data retrieval by fetching only necessary attributes, such as 'JobTitle'. ```powershell # Get a Person using its AccountName attribute, and uses the AttributesToGet parameter to return only the JobTitle attribute $obj = Get-Resource -ObjectType Person -AttributeName AccountName -AttributeValue testuser -AttributesToGet JobTitle ``` -------------------------------- ### Define Resource Management Configurations in XML Source: https://docs.lithnet.io/resource-management-powershell/configuration/configuration-management This XML snippet defines various Resource Management configurations such as Sets, Email Templates, Workflow Definitions, and Management Policy Rules. It uses variables for dynamic values and references other resources using XML references. The configurations are intended to be applied using the Import-RMConfig cmdlet. ```xml DisplayName ___Demo Set Contains all the test users for the purpose of this demo /Person[starts-with(AccountName, 'testuser')] DisplayName ___Demo Email Template An email template created for the purpose of this demo Notification #PATH#Templates\EmailTemplate.html Hello FIM user group DisplayName ___Demo Workflow Definition Sends an account expiry notification email to users email address2 #PATH#Templates\WFDemo.xml Action false DisplayName ___Demo MPR - Triggers Workflow Triggers the "##xmlref:demoWorkflowDefinition:DisplayName##" workflow when a user account transitions into the "##xmlref:demoSet:DisplayName##" set * TransitionIn demoWorkflowDefinition false false SetTransition demoSet ``` -------------------------------- ### Create and View XPath Query Component (PowerShell) Source: https://docs.lithnet.io/resource-management-powershell/usage/cmdlet-reference/new-xpathquery Demonstrates how to create a basic XPath query component using New-XPathQuery and then view its string representation. This cmdlet returns only a component, not a full query. ```powershell $query = New-XPathQuery -AttributeName "AccountName" -Operator Equals -Value "ryan" $query.ToString() ``` -------------------------------- ### Iterate through result set one page at a time using Search-ResourcesPaged Source: https://docs.lithnet.io/resource-management-powershell/usage/cmdlet-reference/search-resourcespaged This PowerShell code demonstrates how to use the Search-ResourcesPaged cmdlet to retrieve and iterate through a result set one page at a time. It initializes a pager, sets the page size, and then loops through the results using GetNextPage() until all items are processed. ```powershell # Get a pager to enumerate all sets $pager = Search-ResourcesPaged -Xpath "/Set"; $pager.PageSize = 10; # Loop through the result set until there are no more results while ($pager.HasMoreItems) { # Get 10 results $resultSet = $pager.GetNextPage(); # Iterate through each result and print the ObjectID foreach($result in $resultSet) { $result.ObjectID } # Repeat until all results have been processed } ``` -------------------------------- ### Search FIM/MIM Resources with PowerShell Source: https://docs.lithnet.io/resource-management-powershell/usage/cmdlet-reference/search-resources This cmdlet enables searching for multiple objects within the FIM Service using XPath queries. By default, it returns basic attributes like ObjectType, ObjectID, and DisplayName. Users can specify `ExpectedObjectClass` or `AttributesToGet` to customize the returned data. The `Unconstrained` parameter offers broader schema access but should be used cautiously due to performance implications. ```powershell # Get all sets, returning only default attributes Search-Resources -Xpath "/Set" # Get users with AccountName starting with 't', returning specific attributes Search-Resources -Xpath "/Person[starts-with(AccountName, 't')]" -AttributesToGet @("AccountName","Domain") # Get first 20 users matching criteria, sorted by DisplayName and AccountName Search-Resources -Xpath "/Person[starts-with(AccountName, 't')]" -AttributesToGet @("AccountName","Domain") -MaxResults 20 -SortAttributes @("DisplayName","AccountName") # Get all workflow definition objects, returning all attributes for that type Search-Resources -Xpath "/WorkflowDefinition" -ExpectedObjectType WorkflowDefinition # Get resources using the XPath query builder (requires New-XPathQuery and New-XPathExpression cmdlets) # $query = New-XPathQuery -AttributeName "AccountName" -Operator Equals -Value "ryan" # $expression = New-XPathExpression -ObjectType "Person" -QueryObject $query # Search-Resources $expression # Get localized object descriptions (e.g., Italian) Search-Resources -XPath "/ObjectTypeDescription" -ExpectedObjectType "ObjectTypeDescription" -Locale it-IT ``` -------------------------------- ### ConfigSync File Structure (XML) Source: https://docs.lithnet.io/resource-management-powershell/configuration/configsync-file This snippet shows the basic XML structure of a ConfigSync file. It includes placeholders for the Variables and Operations elements, which define the configuration's objects, attributes, and operations. ```xml ... ... ``` -------------------------------- ### Import Configuration from XML File - PowerShell Source: https://docs.lithnet.io/resource-management-powershell/usage/cmdlet-reference/import-rmconfig The Import-RMConfig cmdlet imports a configuration definition from a specified XML file. It can optionally preview changes without committing them and log detailed attribute changes to the console. ```powershell Import-RMConfig -File EmailTemplateConfig.xml ``` -------------------------------- ### Reject All Pending Requests via Pipeline in PowerShell Source: https://docs.lithnet.io/resource-management-powershell/usage/cmdlet-reference/set-pendingapprovalrequest This snippet illustrates how to reject all pending approval requests using the PowerShell pipeline. Get-ApprovalRequest filters for 'Pending' status, and the results are piped to Set-PendingApprovalRequest with the 'Reject' decision and a specified reason. ```powershell Get-ApprovalRequest -Status Pending | Set-PendingApprovalRequest -Decision Reject -Reason "Not today" ``` -------------------------------- ### Create and View XPath Query Group String - PowerShell Source: https://docs.lithnet.io/resource-management-powershell/usage/cmdlet-reference/new-xpathquerygroup Demonstrates how to create a simple XPath query group using New-XPathQuery and New-XPathQueryGroup, and then view its string representation. This cmdlet returns a component of a query, not a complete, usable query on its own. ```powershell $query1 = New-XPathQuery -AttributeName "AccountName" -Operator Equals -Value "ryan" $query2 = New-XPathQuery -AttributeName "AccountName" -Operator Equals -Value "bob" $queryGroup = New-XPathQueryGroup -Operator Or -Queries @($query1, $query2) $queryGroup.ToString() ``` -------------------------------- ### Approve Pending Approval Requests with PowerShell Source: https://docs.lithnet.io/resource-management-powershell/usage/cmdlet-reference/set-pendingapprovalrequest This snippet demonstrates how to retrieve pending approval requests using Get-ApprovalRequest and then approve each one individually using Set-PendingApprovalRequest. It iterates through requests and sets the decision to 'Approved' if the status is 'Pending'. ```powershell $requests = Get-ApprovalRequest foreach ($request in $requests) { if ($request.Status -eq "Pending") { Set-PendingApprovalRequest -ApprovalObject $request -Decision Approved } } ``` -------------------------------- ### Set Date Attributes using PowerShell Source: https://docs.lithnet.io/resource-management-powershell/help-and-support/working-with-different-data-and-attribute-types Demonstrates setting the ExpiryDate attribute for a resource using both native DateTime objects and ISO8601 formatted strings in PowerShell. The client accepts both formats, but string dates must be in universal time. ```powershell # Sets the expiry date to the current date and time $obj = Get-Resource -ObjectType Person -AttributeName AccountName -AttributeValue testuser $obj.ExpiryDate = [DateTime]::Now Save-Resource $obj # Sets the expiry date to a specific value $obj.ExpiryDate = "2020-01-01T00:00:00.000" Save-Resource $obj ``` -------------------------------- ### Default XSD Schema for Resource Management Configuration Source: https://docs.lithnet.io/resource-management-powershell/configuration/configuration-management This is the complete XSD schema used for validating Resource Management Configuration files. It defines elements and attributes for operations like adding, updating, and deleting resources, as well as managing their attributes. ```xml ``` -------------------------------- ### Build Simple XPath Query with New-XPathQueryGroup - PowerShell Source: https://docs.lithnet.io/resource-management-powershell/usage/cmdlet-reference/new-xpathquerygroup Illustrates building a complete XPath expression by combining New-XPathQueryGroup with New-XPathExpression. The resulting expression can be used to search for resources based on the defined query criteria. ```powershell $query1 = New-XPathQuery -AttributeName "AccountName" -Operator Equals -Value "ryan" $query2 = New-XPathQuery -AttributeName "AccountName" -Operator Equals -Value "bob" $queryGroup = New-XPathQueryGroup -Operator Or -Queries ($query1, $query2) $expression = New-XPathExpression -ObjectType "Person" -QueryObject $queryGroup $expression.ToString() ``` -------------------------------- ### Set Binary Attributes using PowerShell Source: https://docs.lithnet.io/resource-management-powershell/help-and-support/working-with-different-data-and-attribute-types Illustrates setting binary attributes like ObjectSID in PowerShell. This can be achieved using a byte array or a base-64 encoded binary string. ```powershell # Sets the value of the ObjectSID attribute to a base-64 encoded string $obj = Get-Resource -ObjectType Person -AttributeName AccountName -AttributeValue testuser $obj.ObjectSID = "AQUAAAAAAAUVAAAAFYLkaG79nJrWb05iFzcCAA==" Save-Resource $obj # Sets the value of the ObjectSID attribute to a byte array $obj = Get-Resource -ObjectType Person -AttributeName AccountName -AttributeValue testuser $obj.ObjectSID = [Byte[]] (0, 1, 2, 3) Save-Resource $obj ``` -------------------------------- ### Define Resource Operations (XML) Source: https://docs.lithnet.io/resource-management-powershell/configuration/operations-element/resourceoperation-element Demonstrates how to define different resource operations (Add, Update, Delete, Add Update) using the XML element. This element is crucial for configuring resource management tasks. ```xml ... ``` ```xml ... ``` ```xml ... ``` ```xml ... ``` -------------------------------- ### Configure FIM Service Connection with Set-ResourceManagementClient (PowerShell) Source: https://docs.lithnet.io/resource-management-powershell/usage/cmdlet-reference/set-resourcemanagementclient This cmdlet configures the connection to the FIM Service. It allows specifying the base address, credentials, Service Principal Name (SPN), and options for Kerberos authentication and schema refresh. Dependencies include the FIM Service and PowerShell. ```powershell Set-ResourceManagementClient -BaseAddress http://fimservice:5725 Set-ResourceManagementClient -BaseAddress http://fimservice:5725 -ServicePrincipalName FIMService/otherhostname Set-ResourceManagementClient -ForceKerberos $false Get-Credential | Set-ResourceManagementClient -BaseAddress http://fimservice:5725 ``` -------------------------------- ### Get-Resource Source: https://docs.lithnet.io/resource-management-powershell/usage/cmdlet-reference/get-resource The Get-Resource cmdlet allows you to retrieve a single object from the FIM Service. It supports retrieval by ID, or by unique attribute name/value pairs. ```APIDOC ## GET /resource ### Description Retrieves a single object from the FIM Service based on its ID or unique attribute pairs. ### Method GET ### Endpoint /resource ### Parameters #### Query Parameters - **ID** (string | GUID | object) - Required - The unique identifier of the resource to retrieve. - **ObjectType** (string) - Optional - The type of the object to query (e.g., 'Person'). Required if not using ID. - **AttributeName** (string) - Optional - The name of the anchor attribute to query with. Required if not using ID and searching by attribute. - **AttributeValue** (object) - Optional - The value of the anchor attribute to query with. Required if not using ID and searching by attribute. - **AttributeValuePairs** (Hashtable) - Optional - A hashtable of attribute and value pairs that uniquely identify the object. Required if not using ID and searching by attribute pairs. - **AttributesToGet** (string[]) - Optional - A list of attributes to retrieve for the object. If omitted, all attributes are returned. - **Locale** (string) - Optional - The culture code for localizing the resource representation (e.g., 'en-US', 'it-IT'). ### Request Example ```json { "example": "GET /resource?ID='7fb2b853-24f0-4498-9534-4e10589723c4'" } ``` ```json { "example": "GET /resource?ObjectType=Person&AttributeName=AccountName&AttributeValue=testuser" } ``` ```json { "example": "GET /resource?ObjectType=Person&AttributeName=AccountName&AttributeValue=testuser&AttributesToGet=JobTitle" } ``` ```json { "example": "GET /resource?ObjectType=Person&AttributeValuePairs=@{AccountName='testuser'; Domain='fim-dev1'}" } ``` ```json { "example": "GET /resource?ObjectType=AttributeTypeDescription&AttributeName=Name&AttributeValue=DisplayName&Locale=it-IT" } ``` ### Response #### Success Response (200) - **Attributes** (object) - A dictionary containing the attributes of the retrieved resource. #### Response Example ```json { "example": { "odata.metadata": "...", "odata.type": "...", "Id": "...", "CreatedTime": "...", "CreatedBy": "...", "LastModifiedTime": "...", "LastModifiedBy": "...", "DisplayName": "...", "AccountName": "testuser", "JobTitle": "Software Engineer" } } ``` ``` -------------------------------- ### Reference Existing FIM Service Object (XML) Source: https://docs.lithnet.io/resource-management-powershell/configuration/building-references This snippet illustrates how to reference an object that already exists in the FIM Service, such as a built-in object. It utilizes the 'reference' type on an AttributeOperation to specify the object by its type and anchor attribute. ```xml Set|DisplayName|Administrators ``` -------------------------------- ### Refresh Resource Management Client Schema with PowerShell Source: https://docs.lithnet.io/resource-management-powershell/usage/cmdlet-reference/update-resourcemanagementclientschema The Update-ResourceManagementClientSchema cmdlet refreshes the client's local copy of the schema from the Resource Management service. This operation is crucial after making any modifications to resource types, attributes, or binding objects to ensure the client reflects the latest schema definitions. The cmdlet requires no parameters for execution. ```powershell Update-ResourceManagementClientSchema ``` -------------------------------- ### Build Nested XPath Query with New-XPathQueryGroup - PowerShell Source: https://docs.lithnet.io/resource-management-powershell/usage/cmdlet-reference/new-xpathquerygroup Shows how to create a nested XPath query structure by including one XPath query group within another. This allows for complex logical combinations of multiple query conditions using 'And' and 'Or' operators. ```powershell $query1 = New-XPathQuery -AttributeName "DisplayName" -Operator StartsWith -Value "ryan" $query2 = New-XPathQuery -AttributeName "DisplayName" -Operator Equals -Value "bob" # Create the child group $queryGroup1 = New-XPathQueryGroup -Operator Or -Queries @($query1, $query2) $query3 = New-XPathQuery -AttributeName "Email" -Operator IsPresent # Create the parent group using the child group and another query $queryGroup2 = New-XPathQueryGroup -Operator And -Queries @($query3, $queryGroup1) $expression = New-XPathExpression -ObjectType "Person" -QueryObject $queryGroup2 $expression.ToString() ``` -------------------------------- ### Build XML Wrapped Filter Expression in PowerShell Source: https://docs.lithnet.io/resource-management-powershell/usage/cmdlet-reference/new-xpathexpression This snippet demonstrates how to construct an XPath query and expression in PowerShell, specifically enabling the wrapping of the resulting expression within an XML filter element. This is useful for creating filter values compatible with Lithnet Resource Management attributes. ```powershell $query = New-XPathQuery -AttributeName "AccountName" -Operator Equals -Value "ryan" $expression = New-XPathExpression -ObjectType "Person" -QueryObject $query -WrapFilterXml $expression.ToString() ``` -------------------------------- ### Set Integer Attributes using PowerShell Source: https://docs.lithnet.io/resource-management-powershell/help-and-support/working-with-different-data-and-attribute-types Explains how to set integer attributes like 'FreezeCount' in PowerShell. Values can be provided as native integers (Int32/Int64) or as strings that can be converted to Int64. ```powershell # Sets the freeze count using an integer value $obj = Get-Resource -ObjectType Person -AttributeName AccountName -AttributeValue testuser $obj.FreezeCount = 5 Save-Resource $obj # Sets the freeze count using a string value $obj = Get-Resource -ObjectType Person -AttributeName AccountName -AttributeValue testuser $obj.FreezeCount = "5" Save-Resource $obj ``` -------------------------------- ### Create Basic XPath Expression - PowerShell Source: https://docs.lithnet.io/resource-management-powershell/usage/cmdlet-reference/new-xpathexpression Creates a basic XPath expression to search for objects with specific attribute values. This expression can be converted to a string or used with other cmdlets. ```powershell # Creates an expression that searches for users with the account name 'ryan' $query = New-XPathQuery -AttributeName "AccountName" -Operator Equals -Value "ryan" $expression = New-XPathExpression -ObjectType "Person" -QueryObject $query $expression.ToString() ``` -------------------------------- ### Query Reference Attribute using XPath Expression (PowerShell) Source: https://docs.lithnet.io/resource-management-powershell/usage/cmdlet-reference/new-xpathquery Demonstrates a more advanced use case where an XPath expression is used as the value to query a reference attribute (e.g., 'Manager'). This involves nesting XPath queries. ```powershell # Build an expression to find a user by its account name $query = New-XpathQuery -AttributeName "AccountName" -Operator Equals -Value "ryan" $expression = New-XPathExpression -ObjectType "Person" -Query $query # Build a query to find all users with a manager who has the account name 'ryan' $derefQuery = New-XpathQuery -AttributeName "Manager" -Operator Equals -Value $expression $derefExpression = New-XPathExpression Person $derefQuery $derefExpression.ToString() ``` -------------------------------- ### Use XPath Expression with Search-Resources - PowerShell Source: https://docs.lithnet.io/resource-management-powershell/usage/cmdlet-reference/new-xpathexpression Demonstrates passing a generated XPath expression directly to the Search-Resources cmdlet to find matching objects. This is a common use case for resource discovery. ```powershell # Creates an expression that searches for users with the account name 'ryan' $query = New-XPathQuery -AttributeName "AccountName" -Operator Equals -Value "ryan" $expression = New-XPathExpression -ObjectType "Person" -QueryObject $query Search-Resources $expression ``` -------------------------------- ### Attribute Operation: Import File Content (XML) Source: https://docs.lithnet.io/resource-management-powershell/configuration/operations-element/attributeoperations-element/attributeoperation-element This XML snippet shows an attribute operation that imports the text content of a specified file (e.g., 'myworkflow.xml') and saves it to an attribute named 'XOML'. This is useful for loading configuration or workflow definitions. ```xml .\myworkflow.xoml" ```