title: Querying the ManagedBy attribute in PowerShell for AD
body: <p>I have a small script in powershell written to query user groups in a specific OU in AD to get the name of those groups and to also try and get the ManagedBy attribute of those groups.  I've been searching online and here for solutions to why the ManagedBy attribute is not populated results but I have had no luck.  Every solution I have found has been written in C# (or another language) and I have tried using the Quest software for AD which doesn't seem to help.  </p>
  
  <pre><code>$test = 'OU=example,DC=example,DC=test'
  
  $test | ForEach {Get-ADGroup -Filter * -Properties ManagedBy -SearchBase $_ } | Select Name, Properties | Sort -Property Name | Out-File C:\test.csv
  </code></pre>
  
  <p>I am only getting results of the name of the groups and empty brackets for the ManagedBy attribute.  My question is, is there anyway to query the managedby attribute in powershell without using another language or integrating different plugins?  I've never written in C and I would prefer using native powershell if possible.  </p>