title: Powershell Get-ADGroup : Cannot bind parameter 'Identity'
body: <p>I am trying to read line by line of a text file into the get-adgroup cmdlet to get a list of which users are a member of the groups from a txt file</p>
  
  <pre><code>Clear-Host;
  $groups = "./desktop/groups.txt"
  $arrayofgroups = Get-Content $groups 
  
  foreach ($item in $arrayofgroups) {
      Get-ADGroup $item -properties * | select samaccountname, members
  }
  </code></pre>
  
  <p>The text file looks like this:</p>
  
  <pre><code>"group 1"
  "group 2"
  </code></pre>
  
  <p>The below code returns:</p>
  
  <blockquote>
    <p>Get-ADGroup : Cannot bind parameter 'Identity' to the target. Exception setting "Identity": "Cannot validate argument on parameter: 'Identity'. The argument is null or empty. Supply an argument that is not
     null or empty and then try the command again."
    At line:6 char:15
    +   {get-adgroup &lt;&lt;&lt;&lt;  $item -properties * | select samaccountname, members}
        + CategoryInfo          : WriteError: (:) [Get-ADGroup], ParameterBindingException
        + FullyQualifiedErrorId : ParameterBindingFailed,Microsoft.ActiveDirectory.Management.Commands.GetADGroup</p>
  </blockquote>
  
  <p>However, when I loop through the array, it returns to the group name ok</p>
  
  <pre><code>Clear-Host;
  $groups = "./desktop/groups.txt"
  $arrayofgroups = Get-Content $groups 
  
  foreach ($item in $arrayofgroups ) {
      $item
  }
  </code></pre>
  
  <p>I have verfied that if you simply run the below it works fine. </p>
  
  <pre><code>get-adgroup "group 1" -properties * | select samaccountname, members
  </code></pre>
  
  <p>I'm new to PowerShell from VBscript, and am not sure why this doesn't work, any thoughts?</p>