Solved

Quest script not outputing in the correct format

Posted on 2014-03-19
2
309 Views
Last Modified: 2014-03-19
Hi ALL !!

Can someone help me on why the output file does not have it in the order I want ?

I want in the order of:
UsrSAmAccountName,Name,Groups,GrpDescription

And its outputting in order:
UsrSAmAccountName,Groups,UserName,GrpDescription

Add-PSSnapin *Quest* -ErrorAction SilentlyContinue
$input= "e:\Projects\test\users.txt"
$Output = "e:\Projects\test\test_Groups.csv"
Get-Content $input | % {
$user = Get-QADUser -sAMAccountName $_
New-Object Psobject -Property @{"UsrSAmAccountName"=$user.SAmAccountName;"UserName"=$user.Name;"Groups"="";"GrpDescription"=""}

ForEach ($Group in $user.memberof) {
            $Grp= Get-QADGroup $group
            New-Object Psobject -Property @{"UsrSAmAccountName"=$user.SAmAccountName;"UserName"="";"Groups"=$Grp.Name;"GrpDescription"=$Grp.Description}
    }
} | Export-CSV -Path $Output -NoTypeInformation
0
Comment
Question by:MilesLogan
2 Comments
 
LVL 39

Accepted Solution

by:
footech earned 500 total points
ID: 39941097
You need to add a Select-Object command in front of the Export-CSV and manually specify the order of columns you want.
 } | Select UsrSAmAccountName,Name,Groups,GrpDescription | Export-CSV -Path $Output -NoTypeInformation 

Open in new window


I can't say exactly why it chooses a particular order.  At one time I thought it was alphabetical according to the name of the property, but I don't believe that is right.  Haven't really investigated...
0
 
LVL 2

Author Closing Comment

by:MilesLogan
ID: 39941114
That was it !! thanks so much !
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Exchange Powershell Help 3 33
NTFS Permissions 6 45
Set up secondary Domain Controller 4 70
Need some powershell help please 5 24
In this article, we will see the basic design consideration while designing a Multi-tenant web application in a simple manner. Though, many frameworks are available in the market to develop a multi - tenant application, but do they provide data, cod…
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question