Options

Powershell command get-ADGroupMember export to file

TheFORCETheFORCE Member Posts: 2,297 ■■■■■■■■□□
I'm having some issues running this command, not sure if i have insufficient rights or if it's something else. To be more specific.
I can run the command get-adgroupmember and then I'm being prompted to enter an identity. I enter the group name as a parameter and the command executes. However once it has been completed i cannont scroll up and export all the group members.
So instead i run the following command get-adgroupmember -identity"group1" | select name | Export-csv -path C:\output\group.csv -notypeinformation
i hit enter and i get "》" and there is no output file anywhere. Am I running the command correctly?

Comments

  • Options
    SlowhandSlowhand Mod Posts: 5,161 Mod
    I tried the same thing, and I'm not getting an error or the "expected input" prompt. It runs and exports to a csv just fine. I'm assuming that you're running this on Windows Server 2003 since you posted it in the MCSA/MCSE 2003 section of the forum, but what version of PowerShell are you running?

    Free Microsoft Training: Microsoft Learn
    Free PowerShell Resources: Top PowerShell Blogs
    Free DevOps/Azure Resources: Visual Studio Dev Essentials

    Let it never be said that I didn't do the very least I could do.
  • Options
    TheFORCETheFORCE Member Posts: 2,297 ■■■■■■■■□□
    Slowhand wrote: »
    I tried the same thing, and I'm not getting an error or the "expected input" prompt. It runs and exports to a csv just fine. I'm assuming that you're running this on Windows Server 2003 since you posted it in the MCSA/MCSE 2003 section of the forum, but what version of PowerShell are you running?

    Slowhand i will have to get you that information in the morning as i am not in the office now. But would the version matter for a command like this? I do not have local admin rights on my machine or elevated access rights in AD. The most i can do is run some queries and searches. Could that be the issue?
  • Options
    ShdwmageShdwmage Member Posts: 374
    TheFORCE, are you putting a space between the -identity and the "group1"
    get-adgroupmember -identity"group1" | select name | Export-csv -path C:\output\group.csv -notypeinformation
    

    It should look something like this:
    get-adgroupmember -identity "group1" | select name | Export-csv -path C:\output\group.csv -notypeinformation
    

    Additionally have you tried to run it without the export to see if the core portion of the command is working properly?
    --
    “Hey! Listen!” ~ Navi
    2013: [x] MCTS 70-680
    2014: [x] 22-801 [x] 22-802 [x] CIW Web Foundation Associate
    2015 Goals: [] 70-410
  • Options
    TheFORCETheFORCE Member Posts: 2,297 ■■■■■■■■□□
    Thanks guys I was able to figure it out. I think the issue might have been the version as Slowhand suggested. I'm using powershell version 2.0. I created the path and an emoty output file and run the command. The information was exported to the file.
  • Options
    SlowhandSlowhand Mod Posts: 5,161 Mod
    I was kind of thinking that your issue might've been with the version. Export-CSV was a bit wonky in 2.0. Also, if you didn't have the C:\Output folder already created, that would've given you an error, but it shouldn't have sat there waiting for you to put further input.

    Free Microsoft Training: Microsoft Learn
    Free PowerShell Resources: Top PowerShell Blogs
    Free DevOps/Azure Resources: Visual Studio Dev Essentials

    Let it never be said that I didn't do the very least I could do.
  • Options
    TheFORCETheFORCE Member Posts: 2,297 ■■■■■■■■□□
    Slowhand wrote: »
    I was kind of thinking that your issue might've been with the version. Export-CSV was a bit wonky in 2.0. Also, if you didn't have the C:\Output folder already created, that would've given you an error, but it shouldn't have sat there waiting for you to put further input.

    Yeah that was probably the issue. The folder not being present. I did some further testing, this time did not create the file and used the existing folder. The command run fine and it created the csv file on its own.
Sign In or Register to comment.