"YOU Can get what you want if you
help enough other people to get what they Want".
The Powershell way of doing thing,Feel Free to Tweak it as per your need
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#------------------------------------------------------------------------------------ | |
# Adding Multiple user to Group in FIM portal | |
#-------------------------------------------------------------------------------------- | |
If(@(Get-PSSnapin | Where-Object {$_.Name -eq "FIMAutomation"} ).count -eq 0) {Add-PSSnapin FIMAutomation} | |
$input = Get-Content C:\Users\Userlist.txt # Path of Txt having display name of the user | |
#--------------------------------------------------------------------------------------- | |
foreach( $b in $input) | |
{ | |
$a = "YOUR GROUP NAME" | |
Function GetUser($b) | |
{ | |
Export-FIMConfig -Uri http://localhost:5725 -onlyBaseResources ` | |
-customConfig "/Person[DisplayName = '$b']" | |
} | |
Function GetGroup | |
{ | |
param($Filter) | |
End | |
{ | |
Export-FIMConfig -Uri http://localhost:5725 -onlyBaseResources ` | |
-customConfig "$Filter" | |
} | |
} | |
$groupObject = GetGroup -Filter "/Group[DisplayName = '$a']" | |
$userObject = GetUser $b | |
$importChange = New-Object Microsoft.ResourceManagement.Automation.ObjectModel.ImportChange | |
$importChange.Operation = 0 | |
$importChange.AttributeName = "ExplicitMember" | |
$importChange.AttributeValue = $userObject.ResourceManagementObject.ObjectIdentifier | |
$importChange.FullyResolved = 0 | |
$importChange.Locale = "Invariant" | |
$importObject = New-Object Microsoft.ResourceManagement.Automation.ObjectModel.ImportObject | |
$importObject.ObjectType = "Group" | |
$importObject.TargetObjectIdentifier = $groupObject.ResourceManagementObject.ObjectIdentifier | |
$importObject.SourceObjectIdentifier = $groupObject.ResourceManagementObject.ObjectIdentifier | |
$importObject.State = 1 | |
$ImportObject.Changes = (,$ImportChange) | |
$importObject | Import-FIMConfig -Uri http://localhost:5725 | |
} | |
#-------------------------------------------------------------------------------------- |
No comments:
Post a Comment