Solved

How to output powershell in csv format

Posted on 2015-01-15
2
212 Views
Last Modified: 2015-01-15
This script is used to return a list of users logged onto citrix servers.  Its output is in a text, space deliminated format.
How can the script be modified so it outputs in a comma seperated value (csv)?  This would make it easier to open in Excel.

add-pssnapin citrix* -erroraction silentlycontinue
#write-host (get-date) 

Get-xasession -farm | select-object -property @{N="Date Time";E={Get-date}},AccountName,ServerName,ClientName,BrowserName | Format-Table  -HideTableHeaders  -autosize



#get-xasession -farm | get-member 
#write-host (get-date) $env:computername
#write-host (get-date) $env:computername
#get-xasession -farm | select-object -property AccountName,ServerName,ClientName,BrowserName,ClientIPV4,SessionName | ft  -HideTableHeaders
#Get-xasession -farm | select-object -property @{N="Date Time";E={Get-date}},AccountName,ServerName,ClientName,BrowserName,ClientIPV4,SessionName | Format-Table  -HideTableHeaders  -autosize

Open in new window

0
Comment
Question by:epmmis
2 Comments
 
LVL 68

Accepted Solution

by:
Qlemo earned 500 total points
ID: 40551923
In general and particular, you replace Format-* cmdlets by Export-CSV -NoType file.csv
0
 

Author Closing Comment

by:epmmis
ID: 40552363
Spot on answer.

Did learn that powershell 2 can not append to a .csv file.  Of course powershell is the installed version.  
Used a simple dos copy command to append the files

thanks
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
A safe way to clean winsxs folder from your windows server 2008 R2 editions
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ā€¦
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now