0

I have been working at this for what seems like way too long now. I am pulling all of the ADgroups names and descriptions in my domain. At this point it doesn't necessarily matter but its eating at me.

$exportList = @()
$ADgroups = Get-ADGroup -Filter * -Properties Description

Foreach ($group in $adgroups){
$GroupObj = New-Object System.Object
$GroupObj | Add-Member -Type NoteProperty -Name Name -Value $group.Name
$GroupObj | Add-Member -Type NoteProperty -Name Description -Value $group.Description

$exportList += $GroupObj
}
$exportList | Out-File C:\test\ADGroups.csv

And the file comes out like this where all of the data is within column A

Excel Spreadsheet test output screenshot

but I would like for the name to show in column A and the Description to show in column B I have tried making different Arrays and tried calling the properties in different ways but nothing I have tried yet has worked and I am sure that I am missing something very simple.

1 Answer 1

1

You're using Out-File Instead of Export-CSV which export a text file instead of a comma separated file

Replace the:

$exportList | Out-File C:\test\ADGroups.csv

To:

$exportList | Export-CSV C:\test\ADGroups.csv

Also, You can cut some lines and simply do:

Get-ADGroup -Filter * -Properties Description | 
Select Name,Description | Export-CSV C:\test\ADGroups.csv
Sign up to request clarification or add additional context in comments.

1 Comment

I swear that I did try that at some point but when I just made that small change and nothing else it worked..... Thank you for pointing out my blind spot good sir!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.