Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Struggling with an Export to CSV code

$
0
0

All,

I have the following code that i'm trying to get a CSV file output from however all I end up with is nothing.... no csv file being created.  The Upshot is that I need exported to CSV Username, Group Membership, with which ones are native and which groups are nested for each user.  my current code is.

Import-Module ActiveDirectory
$userlist = Get-ADUser -SearchBase "CN=Users,DC=aronova,DC=com" -Filter * | foreach-object {
#write-host "User:" $_.Name -foreground green
$grouplist = Get-ADPrincipalGroupMembership $_.SamAccountName | foreach-object {
        #write-host "Member Of:" $_.name
{
$o = New-Object PSObject
$0 | add-member NoteProperty UserName = $userlist
$o | add-member NoteProperty Groups = $grouplist
$o | Export-csv c:\tmp\members.csv
    }

    }
}

Any assistance will be gratefully received,


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>