title: How to export these results in a comma delimited csv file
body: <p>I'm trying to determine if there is a way to switch up what I have below and export it in a comma delimited csv file. </p>
  
  <p>The script works fine and returns the data I care about, just not in a usable format. </p>
  
  <p>The script gets users in a specific group and loops through the user list pulling additional information for each user. I'm not familiar with powershell so it's possible I'm making this harder than necessary based on lack of knowledge.</p>
  
  <pre><code>Import-module activedirectory
  
  Function Process-Members($MemberList)
  {
      foreach ($member in $MemberList)
      {
          Get-ADUser -Identity $member.samaccountname -Properties * | select Name, SamAccountName, Enabled, @{Name='LastLogon';Expression={[DateTime]::FromFileTime($_.LastLogon)}}
          dsquery user -samid $member.samaccountname | dsget user -memberof | dsget group -samid
      }
  }
  
  $members = Get-ADGroupMember "MyGroupName" -recursive | Select-Object name, SamAccountName
  
  Process-Members $members
  
  </code></pre>