i have the below powershell script but which will create only one user at time in the FIM. Can somebody help me with powershell scripit which will help us to create a bulk users .
#----------------------------------------------------------------------------------------------------------
set-variable -name URI -value "http://localhost:5725/resourcemanagementservice' " -option constant
#----------------------------------------------------------------------------------------------------------
function SetAttribute
{
PARAM($object, $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 ($object.Changes -eq $null) {$object.Changes = (,$importChange)}
else {$object.Changes += $importChange}
}
}
#----------------------------------------------------------------------------------------------------------
function CreateObject
{
PARAM($objectType)
END
{
$newObject = New-Object Microsoft.ResourceManagement.Automation.ObjectModel.ImportObject
$newObject.ObjectType = $objectType
$newObject.SourceObjectIdentifier = [System.Guid]::NewGuid().ToString()
$newObject
}
}
#----------------------------------------------------------------------------------------------------------
if(@(get-pssnapin | where-object {$_.Name -eq "FIMAutomation"} ).count -eq 0) {add-pssnapin FIMAutomation}
clear-host
if($args.count -ne 1) {throw "You need to specify your attribute values as parameter"}
$attributes = ($args[0]).split("|")
if(0 -ne [String]::Compare(($attributes[0]).split(":")[0],"displayname", $true))
{throw "You need to specify a display name"}
$objectName = ($attributes[0]).split(":")[1]
$exportObject = export-fimconfig -uri $URI `
onlyBaseResources `
-customconfig "/Person[DisplayName='$objectName']"
if($exportObject) {throw "L:User $objectName already exists"}
$newUser = CreateObject -objectType "Person"
foreach($attribute in $attributes)
{
$attrData = $attribute.split(":")
SetAttribute -object $newUser `
-attributeName $($attrData[0]) `
-attributeValue $($attrData[1])
}
$newUser | Import-FIMConfig -uri $URI
write-host "`nUser created successfully`n"
#----------------------------------------------------------------------------------------------------------
trap
{
$exMessage = $_.Exception.Message
if($exMessage.StartsWith("L:"))
{write-host "`n" $exMessage.substring(2) "`n" -foregroundcolor white -backgroundcolor darkblue}
else {write-host "`nError: " $exMessage "`n" -foregroundcolor white -backgroundcolor darkred}
Exit
}
#----------------------------------------------------------------------------------------------------------