none
Exporting data to CSV RRS feed

  • Question

  • Hello,

    I am having an issue with appending printer info to a CSV file it just shows as blank in the file.

    Here is my script

    @echo off

    Echo Querying Programs...Please Wait...

    Powershell -ExecutionPolicy Bypass -Command "& {Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | Export-Csv -Path "C:\programdata\Programs.csv"}"


    Powershell -ExecutionPolicy Bypass -Command "& {Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | Export-Csv -Path "C:\programdata\Programs.csv" -append}"


    Echo. >>"C:\programdata\Programs.csv"
    Echo. >>"C:\programdata\Programs.csv"

    Powershell -ExecutionPolicy Bypass -Command "& {Get-Printer | Select-Object Name, DriverName, PortName | Export-Csv -Path "C:\programdata\Programs.csv" -append -force}"

    Echo. >>"C:\programdata\Programs.csv"
    Echo. >>"C:\programdata\Programs.csv"
    net use >>"C:\programdata\Programs.csv"


    rename "C:\programdata\Programs.csv" "%username% %computername% Programs.csv"


    xcopy "C:\programdata\%username% %computername% Programs.csv" "\\usl5cb2075kgr\SW_Share\User_Programs\" /c /i /y

    Del /q /f "C:\programdata\%username% %computername% Programs.csv"

    The command in bold is what is giving me trouble. any help would be awesome!


    • Edited by Shane199098 Wednesday, January 13, 2016 3:43 AM
    Wednesday, January 13, 2016 3:42 AM

Answers

  • You cannot output different objects to the same CSV.  It wil break the CSV,

    You say you have issues with that one line but fail to say what the issue is.

    "ProgramData" cannot be written to by non-admins.

    Get-Printer is not available before Windows 8.


    \_(ツ)_/

    • Marked as answer by Shane199098 Thursday, January 14, 2016 1:18 AM
    Wednesday, January 13, 2016 7:37 AM

All replies

  • echo >> <file>

    This just erases the file.

    Can you ask the person who wrote this to help you?  You seen to not know what to do next.


    \_(ツ)_/

    Wednesday, January 13, 2016 3:55 AM
  • I wrote this...

    The echo. >> <file> is suppose to just input a space in between the data. I removed this just to check to see if that was indeed the problem but still got the same result.

    Wednesday, January 13, 2016 4:08 AM
  • You cannot output different objects to the same CSV.  It wil break the CSV,

    You say you have issues with that one line but fail to say what the issue is.

    "ProgramData" cannot be written to by non-admins.

    Get-Printer is not available before Windows 8.


    \_(ツ)_/

    • Marked as answer by Shane199098 Thursday, January 14, 2016 1:18 AM
    Wednesday, January 13, 2016 7:37 AM
  • ok thanks I will have to just make a separate file the printers then.
    Thursday, January 14, 2016 1:18 AM