FIM 2010 Portal: Bulk Create Bindings and Attributes from a File via PowerShell

I will be using the Lithnet PowerShell available on Codeplex

Creating Attributes from file

My file looks like this
AttribSystemName;AttribDisplayName
MyNewAttrib;My New Attribute

The PS to create

#Load the Lithnet FIM PowerShell Module
Import-Module LithnetRMA

#Connect to the FIM service instance
Set-ResourceManagementClient -BaseAddress http://localhost:5725

#Read in the file
$file = Get-Content d:\portal\CreateAttrib.txt
for($i=1;$i -lt $file.count;$i++){
#Get the AttributeName from the file
[String]$csvobj = ($file[$i] -split “;”)

# Create a new Attribute object
$obj = New-Resource -ObjectType AttributeTypeDescription
$obj.Name = $csvobj[0]
$obj.DisplayName = $csvobj[1]
$obj.DataType = “String”
$obj.Multivalued = “false”
Save-Resource $obj

Create Bindings from file

We will be binding the attribute to the User Object

My file looks like this
AttribSystemName;AttribDisplayName
MyNewAttrib;My New Attribute

The PS to create
#Load the Lithnet FIM PowerShell Module
Import-Module LithnetRMA

#Connect to the FIM service instance
Set-ResourceManagementClient -BaseAddress http://localhost:5725

#Read in the file
$file = Get-Content d:\portal\CreateBinding.txt
for($i=1;$i -lt $file.count;$i++){
$csvobj = ($file[$i] -split “;”)
$Attrib = $csvobj[0]
$DName = $csvobj[1]

# Create a new binding object
$obj = New-Resource -ObjectType BindingDescription
$obj.BoundAttributeType = Get-Resource -ObjectType AttributeTypeDescription -AttributeName DisplayName -AttributeValue $Attrib
$obj.DisplayName = $DName
$obj.BoundObjectType = Get-Resource -ObjectType ObjectTypeDescription -AttributeName DisplayName -AttributeValue User
$obj.Required = “false”
Save-Resource $obj
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s