I am a little new to PowerShell and am having trouble properly formatting the output of a script I am writing.
The first line of the snippet returns an array of objects of what I'm looking to format (Event ID 372 in the Printer's Event log). The second line prints out the properties I need for the object in position 3:
$error_372 = Get-WinEvent -LogName 'Microsoft-Windows-PrintService/Admin'| ? {$_.Id -eq '372'}
$error_372[3].Properties[0,1,2,4]
The output of the above returns the following:
Value
-----
Print Document
Ahmet
Canon MP560 series Printer
131072
I want all of the objects returned in a format like this:
Document Name User Name Printer Name Document Size
------------- --------- ------------ -------------
Print Document Ahmet Canon MP560... 131072
yada yada yada yada yada
Ultimately, I need this in a CSV but figured I would start with trying to print it on the screen properly.