Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.




30 posts

Geek


Topic # 93578 24-Nov-2011 11:01
Send private message

Hey guys,

I am a powershell noob in anything but exchange, so just looking for a bit of help on this one.

I have a input file, which lists usernames of the users that I am enquiring about.  I need to know all of the groups that the user belongs to AD.  Then once that is created, I need to export to a CSV file.

My progress so far -

import-csv "c:\temp\Users.csv"|foreach{Get-QADmemberof $_.Username -includeallproperties|select-object name,type|export-csv "c:\temp\testOutput.csv" -NoTypeInformation -append }

So from here it does most of what it needs to.  It grabs the details and throw them into a CSV as I need.  But I need it to also have a coloumn on each row advising which user it is querying and if possible a new line between each user that is queried.

Any quick ideas/tips?

Create new topic


30 posts

Geek


  Reply # 550774 28-Nov-2011 08:49
Send private message

I guess that no one knows how to do this from my script.  Any other suggested ways of doing this?



30 posts

Geek


  Reply # 550804 28-Nov-2011 10:01
Send private message

Have found another way of doing this -

$alist = "Name`tAccountName`tDescription`tEmailAddress`tLastLogonDate`tManager`tTitle`tDepartment`tCompany`twhenCreated`tAcctEnabled`tGroups`n"
$userlist = Get-ADUser -Filter * -Properties * | Select-Object -Property Name,SamAccountName,Description,EmailAddress,LastLogonDate,Manager,Title,Department,Company,whenCreated,Enabled,MemberOf | Sort-Object -Property Name
$userlist | ForEach-Object {
    $grps = $_.MemberOf | Get-ADGroup | ForEach-Object {$_.Name} | Sort-Object
    $arec = $_.Name,$_.SamAccountName,$_.Description,$_.EmailAddress,$_LastLogonDate,$_.Manager,$_.Title,$_.Department,$_.Company,$_.whenCreated,$_.Enabled
    $aline = ($arec -join "`t") + "`t" + ($grps -join "`t") + "`n"
    $alist += $aline
}
$alist | Out-File D:\Temp\ADUsers.csv

I will have to remove all the users I dont need from the spreadsheet, but time constraints means I'll have to do it this way rather than fumble through trying to get the code to work again.

Edit - Fix was from the following site/address -

http://stackoverflow.com/questions/4381943/how-to-export-csv-of-active-directory-objects

Create new topic



Twitter »

Follow us to receive Twitter updates when new discussions are posted in our forums:



Follow us to receive Twitter updates when news items and blogs are posted in our frontpage:



Follow us to receive Twitter updates when tech item prices are listed in our price comparison site:



Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.

Alternatively, you can receive a daily email with Geekzone updates.