title: Method invocation failed because [Selected.Microsoft.ActiveDirectory.Mangement.ADGroup] doesn't contain a method named 'substring'
body: <p>I am stumped. I have what I thought should work in a script to pull all groups and get the users in those groups from AD.</p>
  
  <pre class="lang-ps prettyprint-override"><code>    $ADGroupList = Get-ADGroup -Filter * | Select Name | Sort Name
      ForEach($Group in $ADGroupList)
      {
          $GroupName = $Group.substring($Group.length -7, $Group.length -8)
          $members = Get-ADGroupMember -Identity "$GroupName" | Select Name, SAMAccountName | Sort Name
          ForEach($member in $members)
          {
              Write-Host ($member.Name + "," + $member.SAMAccountName  + "," + $Group.name)
          }
      }
  </code></pre>
  
  <p>It keeps failing with the following error:</p>
  
  <blockquote>
    <p>Method invocation failed because [Selected.Microsoft.ActiveDirectory.Mangement.ADGroup] doesn't contain a method named 'substring'</p>
  </blockquote>
  
  <p>Where did I go wrong? I thought <code>SubString</code> was a PowerShell method?</p>