Skip to main content

PowerShell command to export a list of domain users from AD group to a CSV file

Here I go with another post on PowerShell. This time, I would like to share a PowerShell command that will help you to export list of users of particular AD (Active Directory) group to a CSV file.
Run PowerShell and type following commands:

# This will import ActiveDirectory module
Import-Module ActiveDirectory

# This command will export list of users from GroupName to a CSV file
Get-ADGroupMember -Identity "GroupName" -server "TestDomain" -recursive | get-aduser -Properties mail |select name,samaccountname |export-csv -path c:\Script\report.csv -NoTypeInformation

In above command, replace GroupName with the Group you want to retrieve members list. Type your domain name in place of TestDomain. Once you run above command, it will create a CSV file “Report.CSV” and save it in C:\Script folder.

I hope you find this post very useful.

Disclaimer: www.TechieTalks.co.uk does not conceal the possibility of error and shortcomings due to human or technical factors. www.TechieTalks.co.uk does not bear responsibility upon any loss or damage arising from conduct or activities related to the use of data and information contained in this blog.

Comments

  1. Import-Module ActiveDirectory doesn't work on my CPU. I just get a read text message.

    ReplyDelete
  2. Can you please send us error message?

    ReplyDelete
  3. Hi. I have a problem similar to this. I need to extract data from an old microfisch system. Is there a shellvpower script that will allow me to pull the data from the acetate and save in windows?

    ReplyDelete
  4. Hi,

    To assist further, can you please provide us more info on your current setup?

    Regards,
    TechieTalks team

    ReplyDelete
    Replies
    1. yes its a microfisch system that i need to extract the data from the 5.5 acetate.

      Delete
  5. How can i upload this CSV style sheet onto my html website?

    Thanks,

    Geoff

    ReplyDelete
    Replies
    1. Hi,

      You can export output to HTML file directly instead of CSV file. Use command ConvertTo-HTML instead of Export-CSV.

      Delete Export-CSV -path c:\Script\report.csv -NoTypeInformation

      Replace above line with ConvertTo-HTMl | Out-File c:\Script\report.html

      Regards,
      TechieTalks Team

      Delete
    2. Hi TechieTalks Team,

      Thanks for the fast reply.

      I don't understand sorry. I want to put a CSV style sheet onto my website.

      I went on internet and it said a CSV (Cascading Style Sheets) will let me alter the colors and fonts of my website.

      Thanks friend,

      Geoff

      Delete
    3. http://www.convertcsv.com/csv-to-html.htm

      Delete
  6. Dear Sir/Madam, Glad to send you this business letter, I found you need RFID/NFC card after check your company webpage. Waiting for your kind inquiry! Best regards!

    ReplyDelete

Post a Comment

Popular posts from this blog

Windows 10 phone: This device has been locked for security reasons. Connect your device to a power source for at least two hours, then restart it to try again.

Hi All, this is my very first post on Windows 10 phone. I have a Windows 10 phone. Today, I saw following error message on phone. It didn’t allow me to unlock my phone using 4 digit pin I had set. The “Emergency calls” was the only option available to me. Error: This device has been locked for security reasons. Connect your device to a power source for at least two hours, then restart it to try again. I tried performing soft reboot but it didn’t fix. After doing a bit of research, I found a solution. Make sure that your phone is connected to Internet during this process. To fix this issue, follow these steps: Launch https://account.microsoft.com/devices on a web browser on another PC/Tablet or a smart phone Login using your Microsoft account (it is the same account you’ve used to configure your phone). Once you’ve logged in, Select your phone. On the next page, click on Lock button. A box will appear asking to enter 6 digit pin , a number where you can be reached (op

Fixed: HTC One M8 USB driver doesn’t recognized by Windows 10

Hi friends, recently I upgraded my Windows 7 OS to Windows 10 on my laptop. Everything was working fine until I plugged my HTC One M8 (Android) phone to laptop using USB cable. A message box appeared stating that it could not detect the USB device. I never had any problem when I was using Windows 7. I used to plug my phone to PC using USB cable and access phone storage as USB drive. I typed my query in google and most of the articles suggested that I should installed HTC Sync Manager and then connect my phone. Well, I installed the required application but it did not resolve the issue. Hence, I removed it. This is my 3 rd HTC phone and I started to find out how I can enable USB debugging mode on my phone. This option is hidden by default. To enable this option, follow these steps:  Go to Settings \ About Select Software Information Click on More  option Now, tap on Build number  option six times in a row. A message will be shown saying “ You are now a developer! ” Go

Virtual USB port is missing on Windows 7

Hi All, it has been a long time since I have posted last blog. I was away for a while during Christmas time. Today, I am going to share information about how to get virtual USB port in drop down list while installing local printer (USB) on Windows 7, if it’s not available by default. I followed below steps to add virtual USB port to add USB printer to Windows 7 PC.           Click on Start . Go to Devices and Printers .           Click on Add Printer .           Select Add a local Printer           In Choose a printer port box, select Create a new port option.           From the drop down list, choose Local port and click on Next button.           Port Name dialog box will appear. Type port name USB001 , click on OK           In the step, choose appropriate printer driver from list or provide a driver disk to complete printer driver installation process. I hope you may find this very useful. Disclaimer: www.TechieTalks.co.uk does not conceal the possibility of