How to Use PowerShell to Display the Attributes of an Object Type

# get-object-attributes.ps1
# Prints the attributes of an object class formatted as a table.
# usage:
# get-object-attributes.ps1 [typeName <string>]

param(
 $typeName="Person"
)

Add-PSSnapin FIMAutomation -ErrorAction SilentlyContinue

# This filter is used to simplify the syntax to access object properties.
# For a detailed description check http://espace.cern.ch/idm/Lists/Posts/Post.aspx?ID=31
function PsExportObject() {
 process {
  $importObject = $_
  $psObject = New-Object PSObject
  foreach ($attribute in $importObject.ResourceManagementObject.ResourceManagementAttributes) {
   $name=$attribute.AttributeName
   if ($attribute.IsMultiValue) {
    $value=$attribute.Values
   } else {
    $value=$attribute.Value
   }
   Add-Member -InputObject $psObject -MemberType NoteProperty -Name $name -Value $value
  }
  $psObject
 }
}

$query="/BindingDescription[BoundObjectType=/ObjectTypeDescription[Name='$typeName']]/BoundAttributeType"
$attributes = Export-FIMConfig -CustomConfig $query -OnlyBaseResources | PsExportObject | Format-Table -AutoSize DataType,Multivalued,Name,DisplayName,Description

Comments

Popular posts from this blog

Troubleshooting Netlogon Error Codes

Service Principal Names (SPNs) SetSPN Syntax (Setspn.exe)

Troubleshooting AD Active Directory Replication Error 8456 or 8457: "The source | destination server is currently rejecting replication requests"