There are multiple ways how you can add a network printer to a PC and of course you can do that also with Compliance Settings in Configuration Manager. In PowerShell we can use Add-Printer cmdlet and if you don’t have the latest PowerShell version, then you can use Win32_Printer WMI class to add the Printer. If you don’t want to depend on a specific PowerShell version, then maybe the easiest way is to use Win32_Printer WMI Class.
Here are the scripts/cmdlets that you can use
Discovery Scripts
Option 1
Win32_Printer WMI Class query
Get-WmiObject -Class Win32_Printer -Filter "Name=’\\\\CTTERM\\CTColorPrint01’" | Measure-Object | Select-Object -ExpandProperty Count
Option 2
Get-Printer cmdlet
Get-printer -Name "\\ctterm\CTColorPrint01" -ErrorAction SilentlyContinue | Measure-Object | Select-Object -ExpandProperty Count
Remediation Scripts
Option 1
AddPrinterConnection method in Win32_Printer WMI class
Invoke-WmiMethod -Namespace "root\cimv2" -Class Win32_Printer -Name AddPrinterConnection -ArgumentList \\CTTERM\CTColorPrint01
Option 2
Add-Printer cmdlet
Add-Printer -ConnectionName \\ctterm\CTColorPrint01
Create the Compliance rule in Configuration Manager
1. Launch the Configuration Manager console, navigate to the Assets and Compliance workspace, Compliance Settings, Configuration Items.
2. Create a new Configuration Item, Select Windows and click Next.
3. Select all Operating systems, and click Next.
4. On Settings, click New. In Setting type, select Script and in Data select Boolean
5. On Discovery Script, click Edit Script and set the Script Language to Windows PowerShell
6. On Create Remediation Script, click Edit Script and set the Script Language to Windows PowerShell
7. Enable “Run scripts by using the logged on user credentials” checkbox
8. Select the Compliance Rule tab, and click New. Configure the following values and click OK.
9. Finish the wizard.
10. Create a new Baseline, and add the Color Printer Configuration Item.
11. Deploy the baseline to a User collection
12. Log in to test computer with a standard user account and evaluate the rule
13. Check the Printers
As you see it´s really easy to add network printers with Compliance settings.
Dear Kaido
Thank you for your awesome description. I’m getting the following error:
0X87D00329
Application requirement evaluation or detection failed
Error Category: Discovery
Do you know what the reasons are?
Thanks in advice
Dominik
Would be nice if this worked in windows 7, tested in windows 8 and works wonderfully.
not tried the wmi version yet.
Appears to be outdated powershell commands. Both discovery scripts error out.