Solved

How to output powershell in csv format

Posted on 2015-01-15
2
215 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

After several days of searching and hunting for limited documentation, I wanted to share this guide to hopefully save someone the hassle of trying to figure this out on their own. I have tested this on Xendesktop 7.1 and PS 4.5 running simultaneous…
Exchange server is not supported in any cloud-hosted platform (other than Azure with Azure Premium Storage).
This tutorial will give a an overview on how to deploy remote agents in Backup Exec 2012 to new servers. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as connecting to a remote Back…
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…

948 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

23 Experts available now in Live!

Get 1:1 Help Now