Quantcast
Channel: PowerShell
Viewing all articles
Browse latest Browse all 15370

Powershell pull First & last name, Samaccountname, whencreated, Groups.

$
0
0

This is what I have but not fully to pull to info the way I want.


import-module activedirectory

$userlist = Get-Content 'c:\temp\AllUsersSamaccountname.txt'

Get-ADUser -Filter '*' -Properties memberof | ? {

$userlist -contains $_.SamAccountName} | % {

$username = $_

$groups = $_ | select -Expand memberof | % { (Get-ADGroup $_).Name }

"{0} {1}" -f $username, ($groups -join ', ')

} | Out-File 'c:\temp\AllUserinfo6.CSV'


The output come in this format...

Firstname, lastname, group1, group2, group3, group4

lastname, firstname, group1, group2, group3, group4

I need it like this....

Firstname, lastname, samaccountname, whencreated, group1, group2, group3, group4



Viewing all articles
Browse latest Browse all 15370

Latest Images

Trending Articles



Latest Images

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