I've hit a wall with CoPilot and Gemini, so I'm turning to you all for help! I'm looking for a PowerShell script that prompts for a hostname, retrieves info about who is currently logged in or who last logged in, and then asks for both the printer share and the specific printer to map it to the user's profile. It would also be great if the script could have the option to remove a printer. I'm really hoping this is something that can be accomplished!
3 Answers
Have you thought about using Group Policy for this? It's a lot easier and cleaner than trying to do it all through PowerShell. You can deploy printers using GPO with minimal hassle. Check out some guides if you haven't already!
From what I know about PowerShell scripts for printer mapping, you'll need to ensure the script is running under the user's context. While a login script would work per target device, running it remotely adds a layer of complexity. You could possibly modify the user's registry hive for this purpose, but that’s where things get tricky.
Are you dealing with a standalone network printer that's not registered in Active Directory? If so, you’ll need to use `Add-PrinterPort` to create a TCP/IP port and then `Add-Printer` to map it to the driver and assign a name to it.
You're on the right path, but I’m curious about how you plan to execute this remotely and under the context of the logged-in user.

Totally agree, PowerShell can handle it, but GPO often makes everything a breeze. If a script is a must for you, are you planning to use it as a login script? Seems like it might be overcomplicating your setup.