Powershell - Quick question on how to get the command to export to CSV?
-
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 ? -
Do you want to see the
Get-AdUser | export-csv -path "c:\export.csv" -notypeinformation
at the top of the CSV file? -
@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.
-
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)