Add a Shared Windows Printer for All Users
This recipe adds a shared print-server connection for every user on a Windows device. The example uses the printer share \\arkone\BigDill.
The obvious PowerShell approach uses Add-Printer, but that command adds the connection only for the account running it. The following example works interactively and is intentionally not the Fileset solution:
import-module printmanagement
add-printer -ConnectionName \\arkone\BigDill
Run interactively, this adds the printer for the signed-in administrator. Run as a FileWave Fileset activation script, it adds the printer only for the Windows SYSTEM account, so the signed-in user does not see it.
So, why did this happen? For two important reasons:
- The Add-Printer cmdlet is great, but it ONLY adds a printer for the current user
- When FileWave runs a script, it is always run under the context of the System account
When I investigated further by opening a command prompt as system, I found that in fact my fileset had run fine, and added the printer, but only for the system account.
Test in the same execution context
Script Best Practices explains how to use PsExec to test as SYSTEM. Current FileWave Windows clients run 64-bit; upgraded environments can retain an older 32-bit execution setting, so confirm the Fileset's actual context when troubleshooting.
Use Windows PrintUI for a per-computer printer connection. Microsoft's PrintUI documentation defines /ga for a global add, /gd for a global delete, and /ge to enumerate per-computer connections.
Add this batch code as the Fileset activation script:
@echo off
rundll32 printui.dll PrintUIEntry /ga /n\\arkone\BigDill
The connection becomes available to users at their next sign-in. A forced reboot is not required; pilot the Deployment and let users sign out and back in during a normal maintenance window.
To remove the per-computer connection when the Fileset is removed, use this post-uninstallation script:
@echo off
rundll32 printui.dll PrintUIEntry /gd /n\\arkone\BigDill
Verify the Deployment
- Run
rundll32 printui.dll PrintUIEntry /geas an administrator and confirm that the per-computer connection is listed. - Sign in with a pilot user and confirm the shared printer appears.
- Send a test page. If connection or driver installation fails, verify DNS, print-server access, share permissions, and your organization's Point and Print policy.
- Test Fileset removal and the next user sign-in before expanding the Deployment.
No comments to display
No comments to display