Results 1 to 4 of 4

Thread: How to display powershell script output to XML

  1. #1
    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.

  2. #2
    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.

  3. #3
    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

  4. #4
    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.

Similar Threads

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

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,505,632.08259 seconds with 17 queries