1.1.6/Public/set-AllegisFIMTGSUser.ps1

function set-AllegisFIMTGSUser{
[CmdletBinding()]
param($objectid,$accountname,[string]$fimservice,[string]$FIMuri='http://localhost:5725/ResourceManagementService',[PSCredential]$fimcred)
function CreateObject
{
    <#
    .SYNOPSIS
        Creates a new object of type Microsoft.ResourceManagement.Automation.ObjectModel.ImportObject.
        This object needs to be saved using the SaveObject in order to be commited to the FIMService.
        Supports pipeline input.
    .PARAMETER objectType
        The system name of the FIMService resource type.
    .EXAMPLE
        CreateObject -objectType Person
    .EXAMPLE
        Objects.Type | CreateObject
    #>

 
    PARAM(
         [Parameter(ValueFromPipeline=$true)]
         [string[]]$ObjectType
         )
    BEGIN{}
    PROCESS
    {
       foreach($Type in $ObjectType)
       {
       $NewObject = New-Object Microsoft.ResourceManagement.Automation.ObjectModel.ImportObject
       $NewObject.ObjectType = $Type
       $NewObject.SourceObjectIdentifier = [System.Guid]::NewGuid().ToString()
       return [Microsoft.ResourceManagement.Automation.ObjectModel.ImportObject]$NewObject
       }
    }
    END{} 
}
function SetAttribute
{#Only for SingleValue attributes
    PARAM([Microsoft.ResourceManagement.Automation.ObjectModel.ImportObject]$ImportObject, [string]$AttributeName, $AttributeValue)
    END
    {
        $ImportChange = New-Object Microsoft.ResourceManagement.Automation.ObjectModel.ImportChange
        $ImportChange.Operation = 1
        $ImportChange.AttributeName = $AttributeName
        $ImportChange.AttributeValue = $AttributeValue
        $ImportChange.FullyResolved = 1
        $ImportChange.Locale = "Invariant"
        if ($ImportObject.Changes -eq $null) {$ImportObject.Changes = (,$ImportChange)}
        else {$ImportObject.Changes += $ImportChange}
    }
}
if ($fimservice -ne $null){$fimuri="http://$($fimservice):5725/ResourceManagementService"}
   if(@(Get-PSSnapin | Where-Object {$_.Name -eq "FIMAutomation"} ).count -eq 0) {Add-PSSnapin FIMAutomation -ErrorAction SilentlyContinue}
$importobject=createobject -ObjectType Person
SetAttribute -ImportObject $importObject -AttributeName AccountName -AttributeValue $accountname
SetAttribute -ImportObject $importObject -AttributeName TGS_MV -AttributeValue 'true'
$importobject.TargetObjectIdentifier=[guid]$objectid
$importobject.State=[Microsoft.ResourceManagement.Automation.ObjectModel.ImportState]::Put
$importobject.SourceObjectIdentifier=[guid]$objectid
Import-FIMConfig -Uri $fimuri -ImportObject $importObject -Credential $fimcred
}