Script enables printer driver installation without being a local administrator

Christian E 1 Reputation point
2022-02-03T10:46:43.243+00:00

Hej!

Detta scriptet funkar nästan helt som jag vill. Det ända som jag inte får rätt på är "Serverlist". Här har jag skrivit in vilken server som det bara ska slå på. Men det slår även på vår andra dc. Vad är fel?

if((Test-Path -LiteralPath "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Printers\PointAndPrint") -ne $true) { New-Item "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Printers\PointAndPrint" -force -ea SilentlyContinue };

New-ItemProperty -LiteralPath 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Printers\PointAndPrint' -Name 'RestrictDriverInstallationToAdministrators' -Value 0 -PropertyType DWord -Force -ea SilentlyContinue;

New-ItemProperty -LiteralPath 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Printers\PointAndPrint' -Name 'Restricted' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue;

New-ItemProperty -LiteralPath 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Printers\PointAndPrint' -Name 'TrustedServers' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue;

New-ItemProperty -LiteralPath 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Printers\PointAndPrint' -Name 'InForest' -Value 0 -PropertyType DWord -Force -ea SilentlyContinue;

New-ItemProperty -LiteralPath 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Printers\PointAndPrint' -Name 'NoWarningNoElevationOnInstall' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue;

New-ItemProperty -LiteralPath 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Printers\PointAndPrint' -Name 'UpdatePromptSettings' -Value 2 -PropertyType DWord -Force -ea SilentlyContinue;

New-ItemProperty -LiteralPath 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Printers\PointAndPrint' -Name 'ServerList' -Value 'hei-tsxe.qwerty.local' -PropertyType String -Force -ea SilentlyContinue

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
10,660 questions
Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
12,171 questions
Windows Server Printing
Windows Server Printing
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.Printing: Printer centralized deployment and management, scan and fax resources management, and document services
641 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MotoX80 31,816 Reputation points
    2022-02-03T15:23:18.437+00:00

    The only thing I can't get right is "Serverlist".

    What error do you get? What doesn't work? If you SilentlyContinue then Powershell will not display any error. Remove the ErrorAction from all of your statements, and let if fail.

    But it also hits our second DC.

    You're going to have to provide more details on that problem. We have no idea what role your "second DC" has here.

    0 comments No comments