A few days ago I wrote about a PowerShell Script to Install Printer Drivers.

I noticed there was a problem with this script: some drivers fail to load with error 1797 which means ERROR_UNKNOWN_PRINTER_DRIVER.

I reread the AddPrinterConnection documentation on MSDN but it didn’t mention anything about additional required permissions or anything.

But then I read the remarks sections of the Win32_Printer Class and it mentions that for some operations the SeLoadDriverPrivilege is required.

In VBScript we can indicate it like this:

But how to do this in PowerShell?

I didn’t find a way to enable a specific privilege but we can enable all by setting Scope.Options.EnablePrivileges to $true.

So I modified the script like this: