I have already searched quite a bit to find a satisfying answer to this but could not find it (neither here on SO nor via Google).
I am currently using the following command to get the Name and the Product Version out of all Printer Drivers on a print Server and pipe it to the pipeline:
Get-WmiObject -Class Win32_PrinterDriver | select name, driverpath | %{ $Name = $_.name; $version = (get-item -LiteralPath $_.driverpath).VersionInfo.ProductVersion; write-output ($Name, $Version) }
Technically, this works but the piped Output is ugly. The Output Looks like this:
Remote Desktop Easy Print,3,Windows x64
6.1.7601.17514
PCL6 Driver for Universal Print,3,Windows x64
3.4.100.1
MS Publisher Color Printer,3,Windows x64
6.1.7600.16385
What I want to achieve is something like the following (like the Standard Output of objects which are not piped through the foreach-object) - eg. from the following command:
Get-WmiObject -Class Win32_PrinterDriver | select name, driverpath
The Output of the above command Looks like this:
name driverpath
---- ----------
Remote Desktop Easy Print,3,Windows x64 C:\Windows\system32\spool\DRIVERS\x64\3\mxdwdrv.dll
PCL6 Driver for Universal Print,3,Windows x64 C:\Windows\system32\spool\DRIVERS\x64\3\ricu00gr.dll
Question: How can I prepare the Output within a foreach-object to resemble the above formatting / object piping?
Thanks for any Input.
With Kind regards