[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3062
  • Last Modified:

PowerShell Output to CSV question

I have a simple PS script that get-adgroup and only three of the attributes (Name, authOrig, dLMemSubmitPerms ).  When I run this without the Export-Csv I can see the values, but when I run it with the Export-Csv I get
Users      Microsoft.ActiveDirectory.Management.ADPropertyValueCollection


Get-ADGroup -Filter * -Properties authOrig, dLMemSubmitPerms | select Name, authOrig, dLMemSubmitPerms | Export-Csv C:\Test.csv

Open in new window


Any help is greatly appricated.
0
yo_bee
Asked:
yo_bee
  • 8
  • 5
  • 3
  • +1
1 Solution
 
XaelianCommented:
Can you try select-object instead of select?
0
 
yo_beeDirector of ITAuthor Commented:
Same results.

:(
0
 
XaelianCommented:
Can you post screenshot of what you get in the csv?
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
yo_beeDirector of ITAuthor Commented:
SS01
0
 
XaelianCommented:
Also a quick screenshot of output in PS? Can't login my server atm.
0
 
Stelian StanNetwork AdministratorCommented:
Try to run this:

Get-ADGroup -Filter * -Properties authOrig, dLMemSubmitPerms | Export-Csv C:\Test.csv

When you export to CSV file it's better not to use select, format-table
0
 
yo_beeDirector of ITAuthor Commented:
@Clonyxlro

When I run it that why I just get the default attributes (DN,SID,Name....)

@Xaelian

PS02
0
 
Stelian StanNetwork AdministratorCommented:
Use Out-File instead of Export-Csv

Get-ADGroup -Filter * -Properties authOrig, dLMemSubmitPerms | select Name, authOrig, dLMemSubmitPerms | Out-File D:\test.txt

Open in new window

0
 
XaelianCommented:
Can you try

Get-ADGroup -Filter * -Properties authOrig, dLMemSubmitPerms | select Name, authOrig, dLMemSubmitPerms | out-file C:\Test.csv
0
 
yo_beeDirector of ITAuthor Commented:
@ Xaelian

The issue with that cmdlet is that the Values are truncated.  I need to get the entire array.
0
 
Stelian StanNetwork AdministratorCommented:
This is the right sintax:

Get-ADGroup -Filter * -Properties authOrig, dLMemSubmitPerms | select Name, authOrig, dLMemSubmitPerms | csvde -f file.csv

Open in new window

0
 
XaelianCommented:
Ok maybe if you change output-file or the export-csv with csvd -f, it could work. Can't copy paste at the moment with my mobile device.
0
 
yo_beeDirector of ITAuthor Commented:
This is dumping the entire AD and it does not have the attributes I am looking for.
0
 
Krzysztof PytkoActive Directory EngineerCommented:
Just only give to you some hints as I'm not that good in PowerShell as others. This is related with variables output, you need to convert them to string before exporting to CSV file.

Please take a look at this answered post on Microsoft Technet forum and try to implement that in your script
http://social.technet.microsoft.com/Forums/en-US/winserverpowershell/thread/eb58b98b-cd3f-4ad9-b75f-cf50abb80d31/

Regards,
Krzysztof
0
 
yo_beeDirector of ITAuthor Commented:
What if I took  the attribute that is multivalued array and then loop through that to get the names?

Would that work.  If so what steps would I take to do this?
0
 
yo_beeDirector of ITAuthor Commented:
I ended up using the information from the link that iSeik posted.
I still need to loop through the array, but that is another question and another time.

Thank you all for you assistance and guidance.
0
 
yo_beeDirector of ITAuthor Commented:
To add to this.
I found a way to get to the final result.
Import-Module ActiveDirectory

$GroupList = Get-ADGroup -Filter * 

foreach ($group in $GroupList)
{
    If ($group.name -eq 'Partners')
    {
        Write-host $group.name
        
        (Get-ADgroup -identity $group.name -Properties authOrig| Select-Object authOrig).authOrig |Get-ADuser |Select Name 
        (Get-ADgroup -identity $group.name -Properties dLMemSubmitPerms| Select-Object dLMemSubmitPerms).dLMemSubmitPerms |Get-ADGroup |Select Name 
        
       
    }
 }

Open in new window

0

Featured Post

Free tool for managing users' photos in Office 365

Easily upload multiple users’ photos to Office 365. Manage them with an intuitive GUI and use handy built-in cropping and resizing options. Link photos with users based on Azure AD attributes. Free tool!

  • 8
  • 5
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now