ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Powershell - Quick question on how to get the command to export to CSV?

    IT Discussion
    2
    4
    1.1k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      stess
      last edited by

      So I know that powershell can do many things...and it can get complicated real fast. I want a way to export the command I used on the powershell along with the result to csv file. Is it possible?

      Say the command Get-AdUser | export-csv -path "c:\export.csv" -notypeinformation
      The result I want both Get-AdUser's result and the whole [Get-AdUser | export-csv -path "c:\export.csv" -notypeinformation] as well. Any easy way to pipe this ?

      1 Reply Last reply Reply Quote 0
      • dafyreD
        dafyre
        last edited by

        Do you want to see the
        Get-AdUser | export-csv -path "c:\export.csv" -notypeinformation
        at the top of the CSV file?

        S 1 Reply Last reply Reply Quote 0
        • S
          stess @dafyre
          last edited by

          @dafyre said in Powershell - Quick question on how to get the command to export to CSV?:

          Do you want to see the
          Get-AdUser | export-csv -path "c:\export.csv" -notypeinformation
          at the top of the CSV file?

          I want to see it in the CSV file before the result.
          0_1504028740474_6d5124c1-948c-4b6f-a553-bd9710dd241a-image.png

          1 Reply Last reply Reply Quote 0
          • dafyreD
            dafyre
            last edited by

            You could write-output the whole command something like:

            write-output "my command with all the parameters here"|out-file -filepath export.csv
            mycommand with all the parameters here|export-csv -path export.csv -append -notypeinformation
            

            Or something similar (code typed on the fly, likely has a syntax error or two)

            1 Reply Last reply Reply Quote 3
            • 1 / 1
            • First post
              Last post