Microsoft offers us with Universal print a new modern way of managing and distributing printers. However, universal print is not the optimal solution in every scenario, especially when multifunction devices have special functions such as cost centers or special user interfaces, the range of functions is not sufficient. In such cases, the classic releasing printer in the network via print server has proven its worth. In the Intune policies themselves there is an option to distribute shared printer, but from my experience this policy does not work reliably enough. That's why I created a script that connects the printers when a user logs in and when there is a network change.
Table of Contents
Requirements
- Printers are shared on a print server (AD Join) in the network
- The print server can be reached via FQDN
- The user is synchronized with the on-premises Active Directory
Since "Print Nightmare" the deployment of shared Printers can fail.
Mor info and which settings you need to change you'll find here: Point and Print & Intune | scloud
PowerShell Script
Preparation
In the script itself you have to specify the print server and the printers to be connected. You also have the option of removing existing printers.
Variabel | Inhalt |
---|---|
$Prt_Server Linie 8 | FQDN address of your print server |
$Prt_Shares Linie 9 | Share names of your printers (comma separated and in quotes) |
$REMOVE_fromServer Linie 10+ | $true = only deletes printers with exact share names $false = deletes the printer if the name is included |
$Prt_REMOVEs Line 11+ | Optional, only necessary if you want to remove existing printers. |
When running, the script first checks whether the print server can be reached. If this is not the case, the process is terminated to avoid unnecessary processes on the device. However, if the server is recognized, any specified printer that is not already connected will be connected.
Deploy Printers with Intune
You can download the script in the Endpoint Manager under "Devices > Windows > PowerShell scripts" upload and distribute.
You can use the script to ensure that printer shared with Intune are connected.
Do you now want Windows not to automatically connect any other printers that are on the network? Then I have an article for you here: Disable Windows "Connect printer automatically" - Intune
Hello. Thanks for this. Just an FYI doesn't seem to work in my Environment. Scheduled task is created and everything however printer will not map. Will map with the Add-Printer -ConnectionName $PrinterShareName if I map it manually
You're welcome.
Do you maybe block vbs scripts?
same goes for me scheduled task is created but printer does not map 🙁 vbs scripts are not being blocked tried to run the task manually but still not mapping
I've uploaded a small fix. Previously the transcript for connection could only be created if the user has admin rights.
Now the transcript will be located at: C:\Users\%username%\AppData\Local_MEM
Could you check if it works for you like this?
Mapping still not working...
what does the users log say?
C:\Users\%username%\AppData\Local_MEM
Fyi I think it's because it's trying to map it to the System user and not the user.
The system context shouldn't be a problem. It will create a test as System which will then run as the user on logon and network changes.
Hello! Thank you for the article and script. Like some others have stated, the scheduled task is being created but the installation of the printer is failing. Checking the logs, I am seeing the line detailed below. I've tried adding the printer/server name a bit differently but that made no change. I'm still playing around with the script but as far as I can tell, there should be no reason for the server/printer to not be found...
PS>TerminatingError(Add-Printer): "The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: The specified server does not exist, or the server or printer name is invalid. Names may not contain ',' or '\' characters."
Error adding \\servername.domain.com\printer1234
The specified server does not exist, or the server or printer name is invalid. Names may not contain ',' or '\' characters.
Do you reach the print server if you type in "\\servername.domain.com" in your Windows Explorer?
Hi, I was wondering how would you ammend the script to add a further print server? We have 2 printer servers with 1 printer on each.
You can deploy the script twice. Just make sure you change the PackageName on the second one.
Hi,
The script requires an fqdn, I'm sharing printers from an azure ad joined machine and it doesnt have an fqdn name. any advice on this?
Thanks,
Due to point and print, this may not be possible (unless you allow installation from all sources).
Hi Florian,
it's not clear for me how to uninstall multiple printers from hosts between lines, can you wrote an example?
You can define that between line 12 and 14.
To remove every printer which is not defined in the script. The option in the sample is on (
$REMOVE_oldPrts = $true
).