How to Use PowerShell to List the Selected Attributes of a Management Agent
FIM ScriptBox Item
Summary
The script displays the selected attributes of a management agent.
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 |
#---------------------------------------------------------------------------------------------------------- $xmlFileName = $myInvocation.mycommand.Path -replace ".ps1",".xml" if($args.count -ne 1) {throw "Missing MA name parameter"} $maName = $args[0] $xmlFileName = $myInvocation.mycommand.Path -replace ".ps1",".xml" if(@(get-pssnapin | where-object {$_.Name -eq "FIMAutomation"} ).count -eq 0) {add-pssnapin FIMAutomation} $exportData = export-fimconfig -uri "http://localhost:5725/resourcemanagementservice" ` –onlyBaseResources ` -customconfig ("ma-data[DisplayName='$maName']") ` -ErrorVariable Err ` -ErrorAction SilentlyContinue if($Err){throw $Err} if($exportData -eq $null) {throw "Object not found"} $attrList = $exportData.ResourceManagementObject.ResourceManagementAttributes | Where-Object {$_.AttributeName -eq "SyncConfig-attribute-inclusion"} [xml]$xmlAttrs = "" + $attrList.Value + "" #---------------------------------------------------------------------------------------------------------- clear-host write-host "Selected Attributes" write-host "===================" if($attrList -eq $null) {"There are no attributes selected"} else {$xmlAttrs.root.attribute | foreach{write-host "- $_"}} write-host "`nCommand completed successfully`n" #---------------------------------------------------------------------------------------------------------- trap { write-host "`nError: $($_.Exception.Message)`n" -foregroundcolor white -backgroundcolor darkred 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.