I have the following code.
$output_status = 0
if($output_status -eq 0){
'All ok'
}
else{
'Error'
}
'----------------------------------------------------------------------------'
'List of all printers'
'----------------------------------------------------------------------------'
$printer_list
'----------------------------------------------------------------------------'
'Driver versions for the printers'
'----------------------------------------------------------------------------'
$Drivers = Get-PrinterDriver | Select-Object Name,@{n="DriverVersion";e={ $ver = $_.DriverVersion;(3..0 | ForEach-Object { ($ver -shr ($_ * 16)) -band 0xffff }) -join '.'}}
$Drivers
'----------------------------------------------------------------------------'
if($datas -ne $null){
'Print driver changed date'
'----------------------------------------------------------------------------'
$datas
'----------------------------------------------------------------------------'
}
foreach($item4 in $printers){
$queue1 = Get-PrintJob -PrinterName $item4
if($queue1 -ne $null){
'----------------------------------------------------------------------------'
'Print queue for ' + $item4
$queue1
'----------------------------------------------------------------------------'
}
}
exit $output_status
when I run the above script it shows the following output
All ok
----------------------------------------------------------------------------
List of all printers
----------------------------------------------------------------------------
Name DriverName PrinterStatus ComputerName
---- ---------- ------------- ------------
Microsoft XPS Document Writer Microsoft XPS Document Writer v4 Normal I-HYPERV
Microsoft Print to PDF Microsoft Print To PDF Normal I-HYPERV
----------------------------------------------------------------------------
Driver versions for the printers
--------------------------------------------------------------------------------------------------------------------
Microsoft XPS Document Writer v4
Microsoft Print To PDF
Microsoft enhanced Point and Print compatibility driver
Microsoft enhanced Point and Print compatibility driver
----------------------------------------------------------------------------
but when I just select the following two lines
$Drivers = Get-PrinterDriver | Select-Object Name,@{n="DriverVersion";e={ $ver = $_.DriverVersion;(3..0 | ForEach-Object { ($ver -shr ($_ * 16)) -band 0xffff }) -join '.'}}
$Drivers
and run the selected lines I am getting the following output.
Name DriverVersion
---- -------------
Microsoft XPS Document Writer v4 10.0.17763.1
Microsoft Print To PDF 10.0.17763.1
Microsoft enhanced Point and Print compatibility driver 10.0.17763.1457
Microsoft enhanced Point and Print compatibility driver 10.0.17763.1457
so, my problem is when I run all script why don't I get DriverVersion I try many things but not any success.