Share via


FIM : Group Membership Export GUI with Powershell

Powershell GUI to export the group membership from FIM portal, This will open up a PowerShell console window and simple GUI showing the input box for the name of group and Outbox for the membership of the group.In addition the membership of the group will export with name of the group in CSV in user profile.

To hide the powershell console window running at the background we can use PowerGUI to wrap it as an exe. 
Open the Script in PowerGUI Script Editor and then go to Tools > Compile Script.

001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
053
054
055
056
057
058
059
060
061
062
063
064
065
066
067
068
069
070
071
072
073
074
075
076
077
078
079
080
081
082
083
084
085
086
087
088
#========================FIM Group Membership Export==========================
<# .SYNOPSIS Get Group Membership Export GUI. .DESCRIPTION Based on Xpath Query .NOTES -Author: Allistair Bridges(Anirban) -Email : Anirbansingha@hotmail.com -CreationDate: 9/12/2014 -LastModifiedDate: -Version: 1.0 .LINK Blog: #>
Add-Type -AssemblyName System.Windows.Forms

# Load FIM Module

If(@(Get-PSSnapin | ? { $_.Name -eq "FIMAutomation"}).Count -eq 0)
{
Add-PSSnapin FIMAutomation;
}


#Create function.

$array=@()
function add ($objTextBox1)
  {

     $a1="$objTextBox1"
     $Group = Export-FIMConfig -customConfig "/Person[ObjectID = /Group[DisplayName = '$a1']/ComputedMember]" -Uri "http://localhost:5725" -OnlyBaseResources
     foreach($i in $Group)
          {
            $Name = (($i.ResourceManagementObject.ResourceManagementAttributes | Where-Object {$_.AttributeName -eq "DisplayName"}).Value)
            $Name>>C:\users\$env:USERNAME\desktop\$a1.csv
            $array+="$Name;"
            $outputBox.text = "$array"
           }
    }


#System.Windows.Forms.Form will create a blank form, Lets create a object.

$Form = New-Object system.Windows.Forms.Form
$form.Size = New-Object Drawing.Size @(1000,10000)
$Form.Text = "Powered by LAZY GUYS OF FIM, Version 1 Release"

$Label = New-Object System.Windows.Forms.Label
$Label.Text = "Display Name of the Group"
$Label.BackColor = "Transparent"
$Label.AutoSize = $True
$Form.Controls.Add($Label)


## Create Input BOX1

$objTextBox1 = New-Object System.Windows.Forms.TextBox
$objTextBox1.Location = New-Object System.Drawing.Size(10,40)
$objTextBox1.Size = New-Object System.Drawing.Size(260,20)
$Form.Controls.Add($objTextBox1)
## End of Input Box1

$objTextBox1.Text

## Create OutBOX

$outputBox = New-Object System.Windows.Forms.RichTextBox 
$outputBox.Location = New-Object System.Drawing.Size(10,150) 
$outputBox.Size = New-Object System.Drawing.Size(565,200) 
$outputBox.MultiLine = $True 

$outputBox.ScrollBars = "Vertical" 
$Form.Controls.Add($outputBox)

## End of Outbox

##Create the ADD Button

$Button = New-Object System.Windows.Forms.Button 
$Button.Location = New-Object System.Drawing.Size(1400,130) 
$Button.Size = New-Object System.Drawing.Size(1110,180) 
$Button.Text = "FIM Export Group Membership" 
$Button.Add_Click({add $objTextBox1.Text}) 
$Form.Controls.Add($Button) 

$Button = New-Object System.Windows.Forms.Button 
$Button.Location = New-Object System.Drawing.Size(400,30) 
$Button.Size = New-Object System.Drawing.Size(110,80) 
$Button.Text = "FIM Export Group Membership" 
$Button.Add_Click({add $objTextBox1.Text $objTextBox2.Text}) 
$Form.Controls.Add($Button) 

##End of Button

$Icon = [system.drawing.icon]::ExtractAssociatedIcon($PSHOME + "\powershell.exe")
$Form.Icon = $Icon

$drc = $form.ShowDialog()
#========================End==========================