How to Use PowerShell to Display the Connection State for the Partitions of a Management Agent

FIM ScriptBox Item

Summary

This script displays the connection state for the partitions of  a management agent.
For more details about the return values see GetServerStatus.

Script Code

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
#-------------------------------------------------------------------------------------------------
 If($args.count -ne 1) {throw "MA name missing"}
 $maName = $args[0]
 Clear-Host

 if(@(get-pssnapin | where-object {$_.Name -eq "FIMAutomation"} ).count -eq 0) {add-pssnapin FIMAutomation}

 $exportObject = export-fimconfig -uri "http://localhost:5725/resourcemanagementservice" `
                 â€“onlyBaseResources `
    -customconfig ("ma-data[DisplayName='$maName']") `
    -ErrorVariable Err `
                 -ErrorAction SilentlyContinue 
 if($Err){throw $Err}
 if($exportObject -eq $null) {throw "Management agent not found"}
#--------------------------------------------------------------------------------------------------------------------------
 $lstMA = @(get-wmiobject -Class "MIIS_ManagementAgent"`
             -Namespace "root\MicrosoftIdentityIntegrationServer"`
             -Computername "."`
             -Filter "Name='$maName'") 
 if($lstMA.count -eq 0) {throw "Management agent not found"}
#--------------------------------------------------------------------------------------------------------------------------
 $partitionData = $exportObject.ResourceManagementObject.ResourceManagementAttributes | `
         Where-Object {$_.AttributeName -eq "SyncConfig-ma-partition-data"}

 [xml]$xmlDoc = "" + $partitionData.Values + ""
 $partNodes = $xmlDoc.selectNodes("//partition")
 If($partNodes.Count -lt 1) {throw "No partitions found"} 

 foreach($curNode In $partNodes)
 {
  $partName = $curNode.selectSingleNode("name").get_InnerText()
  $partStatus = ($lstMA[0].GetServerStatus($curNode.selectSingleNode("id").get_InnerText())).ReturnValue
  Write-Host $partName": "$partStatus
 }
 Write-Host "`nCommand completed successfully`n"
#------------------------------------------------------------------------------------------------------------
 Trap 
 {
  Write-Host $_.Exception.Message 
  Write-Host "" 
  Exit 
 }
#------------------------------------------------------------------------------------------------------------

 

Note

To provide feedback about this script, create a post on the FIM TechNet Forum.
For more FIM related Windows PowerShell scripts, see the FIM ScriptBox.

 

 

Note

To provide feedback about this script, create a post on the FIM TechNet Forum.
For more FIM related Windows PowerShell scripts, see the FIM ScriptBox.

 


See Also