0

I need to export all of the email addresses from my Local Windows Groups and Users that are active to a CSV file. How do I do this? I am new to Powershell, but I would like to write a PowerShell script to do this. I began by importing the activedirectory module and was able to execute some scripts.
Here is a link that does almost everything except this writes the output to the console instead of CSV. And it freezes and doesn't return to the command prompt after running: groups and users to console solution

So in this CSV, I'd like to see each group header followed by its member email addresses.

salvationishere
  • 3,461
  • 29
  • 104
  • 143
  • Can you use a programming language rather than powershell? – awzx Oct 06 '17 at 22:29
  • 1
    I only linked one duplicate, but there are **many others** (I think > 50% of PowerShell questions here are asking about how to export some such thing to CSV; a good portion of those deal with AD objects). I appreciate that you're new to the language and maybe you've put some effort in and tried some stuff, but you didn't share any of that in the question. – briantist Oct 06 '17 at 22:34
  • I spent all day at work trying out different solutions but none of them successfully exported to CSV. The only ones that worked exported to the console. I will try the solutions from the duplicate question above on Monday. Thanks! – salvationishere Oct 06 '17 at 23:05
  • And yes, I could use a programming language but PowerShell seems easiest to me. – salvationishere Oct 06 '17 at 23:05
  • @salvationishere I know you're not new here, but if you have tried things you should share your code, explain what didn't work or how it didn't do what you wanted/expected. If the duplicate doesn't get you where you need, post a new question, but first see [ask], and provide a [mcve]. – briantist Oct 09 '17 at 14:59
  • This may be a dupe, but simple enough to represent as a oneliner: `Get-ADGroupMember GroupName | Get-ADUser -Properties EmailAddress | Select Name, SamAccountName, EmailAddress | Export-Csv -NoTypeInformation C:\Path\To\file.csv` – codewario Jun 29 '18 at 21:16
  • Thank you, Bender. The problem I had though was that I need all Names and email addresses for my Local Windows Groups (not AD groups). Do you know how to do this? – salvationishere Jul 03 '18 at 15:19

0 Answers0