CreatePerson
Applies To: Forefront Identity Manager 2010
This is an example of a Windows PowerShell function that creates a new Person resource in the Forefront Identity Manager (FIM) Service database. For more information, see FIM Windows PowerShell Cmdlet Examples.
CreatePerson Function
This function creates a new ImportObject object based on a Person resource type. It then uses the SetSingleValue function to add attributes to the object based on the function parameters. The function takes FirstName, LastName, AccountName, Domain, Email, and optional Uri parameters. The DisplayName of the Person is set automatically to be a combination of the FirstName and LastName parameters. The new Person is added to the FIM Service using the Import-FIMConfig cmdlet.
function CreatePerson
{
PARAM($FirstName, $LastName, $AccountName, $Domain, $Email, $Uri = $DefaultUri)
END
{
$DisplayName = [System.String]::Format("{0} {1}", $FirstName, $LastName)
$NewPerson = CreateImportObject -ObjectType "Person"
SetSingleValue $NewPerson "FirstName" $FirstName
SetSingleValue $NewPerson "LastName" $LastName
SetSingleValue $NewPerson "DisplayName" $DisplayName
SetSingleValue $NewPerson "AccountName" $AccountName
SetSingleValue $NewPerson "Domain" $Domain
SetSingleValue $NewPerson "Email" $Email
$UserSid = GetSidAsBase64 -AccountName $AccountName -Domain $Domain
SetSingleValue $NewPerson "ObjectSID" $UserSid
$NewPerson | Import-FIMConfig -Uri $Uri
}
}
The previous code assumes that the following variable is included in the script that contains the CreatePerson function:
$DefaultUri = "https://localhost:5725"
Remarks
You can modify this function to add values to additional attributes of the Person resource or initialize attributes with default values. You can use this function as part of the Windows PowerShell script that creates Person objects as part of a bulk import.
See Also
Reference
Import-FIMConfig
Concepts
FIM Windows PowerShell Cmdlet Examples
SetSingleValue
CreateImportObject
ResolveObject
GetSidAsBase64