Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 01-06-2009
Member
 
Join Date: Apr 2009
Posts: 64
How to display powershell script output to XML

I wanted develop an scripts which will run and provide with the output in a readily usable form, and I wanted them to send their results set to Excel or sometimes Word as well as text files if needed. I tried the above project in the VB script but it seems to be little difficult, i have read some blog where i found that this is possible with the powershell script, if yes then how to achieve this.
please let me know.
Reply With Quote
  #2  
Old 01-06-2009
Member
 
Join Date: Dec 2008
Posts: 183
Re: How to display powershell script output to XML

Powershell script provide you the ability to import and export the Csv file to the expected format.In PowerShell you also have the ability to send your PowerShell command line script results set to Excel (In a round about way, because it is actually a .Csv file) as well as to an XML file by using the Export Cmdlet. For example if you want to export the results set to a Csv file you would use the Export-Csv Cmdlet and if you want the output sent to an Xml file you would use the Export-CliXml Cmdlet.

Note: you can also use the MS-DOS redirect as in the example here: Get-Process > C:\Processes.Txt.
Reply With Quote
  #3  
Old 01-06-2009
Member
 
Join Date: Mar 2008
Posts: 258
Re: How to display powershell script output to XML

You could write to the screen and file by using tee-object like this:

$colItems | select-object CSName, Description, FixComments, HotFixID,InstallDate, InstalledBy, InstalledOn, Name, ServicePackInEffect, Status |tee-object outfile.txt

Importing Cmdlet which will allow to import or to read data from an existing Csv or even a text file and it will display the output in the PowerShell console in a table format as Import-Csv or Import-CliXml as in the examples here:

Import-Csv C:\MyFile.Csv
Import-Csv C:\MyFile.Csv | Sort-Object Name
Reply With Quote
  #4  
Old 01-06-2009
Member
 
Join Date: Jan 2009
Posts: 140
Re: How to display powershell script output to XML

To export a PowerShell command line script output to a Csv file as opposed to the screen you can issue the following in the PowerShell console: Get-Process | Export-Csv C:\MyFile.Csv.Scripting with Windows PowerShell brings together resources for system administrators who are interested in learning about the Windows PowerShell command line and scripting environment. Once the file is created you can then open it in Excel by simply opening the file which is Comma delimited.

If you want to save the results as an Xml file you would issue the following command: Get-Process | Export-CliXml C:\MyFile.Xml.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to display powershell script output to XML"
Thread Thread Starter Forum Replies Last Post
Powershell Script to Enable/Disable Network Connection windows_user Software Development 8 27-04-2012 09:35 PM
Bash script needs to e-mail output Kim|ball Technology & Internet 4 27-05-2011 10:19 AM
Running Powershell script with batch file with parameters? Jaslein Software Development 3 12-01-2011 03:36 AM
Powershell script to parse system logs in text file SADIQ Operating Systems 2 02-06-2009 07:05 PM
Create a script using Powershell Connect_Me Software Development 4 07-02-2009 05:41 PM


All times are GMT +5.5. The time now is 07:49 PM.