r/PowerShell • • May 03 '22

Script to install printer through intune NSFW

Hi Folk

I am trying to install network printers on clients devices through intune. Could you suggest the power shell scrip for that. I have onsite print server installed.

0 Upvotes

24 comments sorted by

3

u/supreme_jackk May 03 '22

-9

u/manjit30 May 03 '22

Thanks you but it doesn't help. The script mentioned in this article doesn't work for me.

8

u/[deleted] May 03 '22

You’d have to provide more context than that….

4

u/Bren0man May 03 '22

Nope. Not gonna happen.

lmao

2

u/Affectionate_Ad_3722 May 03 '22

Can you post the script you are using? Anonymised a bit.

10

u/[deleted] May 03 '22

You may want to do a GPO for this in all honesty. Also why is this set to NSFW?

30

u/Mysterious-Ad-1541 May 03 '22

Printers are dirty

5

u/Bren0man May 03 '22

If you keep touching me like that, I'm going to ink all over you...

- Printers

1

u/The82Ghost May 05 '22

Inktjets be like: squirt squirt

1

u/crimesonclaw May 03 '22

Yeah, gpo or, something new, a group policy for each printer. So you can assign printers in the ad.

4

u/prof_b May 03 '22

Due to the whole PrintNightmare thing we ended up using custom apps via the Company Portal that the user can run to install the printers they want - works pretty well. The setup process is explained here > https://www.usmanghani.co/deploy-network-printer-via-intune

1

u/[deleted] May 03 '22

How many network printers do you have? Is this one site/office? Does this need to be dynamic or the same for every device?

1

u/manjit30 May 04 '22

I have 5-6 multistation printers. Its a school.

1

u/Treblif_dk May 03 '22

In intune you can create configuration profiles that can add one or multible printers and set one off them as default.

1

u/manjit30 May 04 '22

Can you provide any link ?

2

u/gangstanthony May 03 '22

using the IntuneWinAppUtil.exe

from here

https://docs.microsoft.com/en-us/mem/intune/apps/apps-win32-prepare

takes you here

https://github.com/Microsoft/Microsoft-Win32-Content-Prep-Tool

download the exe.

i created a folder for "printer install"

in that folder, there is another folder called drivers that has like 3 files for the printer drivers

also a ps1 script with these lines

C:\Windows\SysNative\pnputil.exe /add-driver "$psscriptroot\Driver\CNLB0MA64.INF" /install
Add-PrinterDriver -Name "canon generic plus ufr ii"

Add-PrinterPort -Name '192.168.1.2' -PrinterHostAddress 192.168.1.2
Add-PrinterPort -Name '192.168.1.3' -PrinterHostAddress 192.168.1.3

Add-Printer "office1 - Canon iR-ADV C5535" -DriverName 'canon generic plus ufr ii' -PortName '192.168.1.2'
Add-Printer "office2 - Canon iR-ADV C5540" -DriverName 'canon generic plus ufr ii' -PortName '192.168.1.3'

then run the intunewinapputil and upload the resulting file into intune

1

u/FlibblesHexEyes May 03 '22

We went the Azure Universal Print path. No drivers to deploy - the user can select the configured drivers from the Settings panel, though there is a tool you can use to automatically deploy the printer queues to the device (it’s name escapes me right now).

Depending on your licensing, you may already have Universal Print available - it just needs to be turned on and configured.

1

u/[deleted] May 03 '22

I am currently setting up UP as well, but in our case we already have 3000+ printers in our environment active that are not UP native. Even if they were the documentation provided by Microsoft show's it would be very hard/impossible to automate the enrollment of that many devices.

I am using UPC and then running scripts to map printers in mass using universal PCL 6 drivers. Then I run scripts to add them to UP in Azure and assign security groups and location attributes so users only see their site printers, with the correct hierarchy info.

1

u/FlibblesHexEyes May 03 '22

We only have the one printer (non-AUP native) - it’s a FollowMe printer, so it’s always one printer queue that you print to, and then when you tap your security card on the printer it dumps the job.

We installed the AUP connector on the printer host to proxy the connection between AUP and the FollowMe queue. It also does on-prem AD user impersonation to match the job to the user tapping on the printer.

To deploy we deploy a Microsoft tool to all the devices via InTune - this tool reads a CSV file that contains the printer name and GUID and auto installs it at login. For the end user this makes it transparent.

But as you say, the AUP printer directory is pretty easy to configure from an Admin point of view, and really easy for an end-user to go find their printer in the directory.

0

u/[deleted] May 03 '22

[deleted]

1

u/manjit30 May 04 '22

Can I have sample please?

1

u/dehin May 03 '22

That just sounds...complicated! I mean the PowerShell script masquerading as an exe wrapped as an IntuneWin file! Just, why?

(Btw, I'm sure you have a good reason, my comment is more tongue in cheek. I am curious how you obfuscate the script as an exe.)

2

u/TestitinProd123 May 03 '22

Mostly because the drivers are stored in an Azure storage blob and pulled down using a SAS which I didn’t really want revealed. I also use exe to obfuscate clients I’ve written that use credentials or keys so that if someone is to browse to the executable they can’t just open it in notepad and pull out potentially usable credentials or secrets.

You can use things like ps2exe or PowerShell ProTools to do the obfuscation.

As for the IntuneWin piece, it’s kind of like a Zip file that contains all the things needed to deploy as a win32 LOB app from endpoint manager, so for example the IntuneWin wrapper might actually contain an executable and dependencies.

I use IntuneWin so that I can leverage managed installer (mark the MEM agent as a managed installer) since MSI are executed by msiexec and not the MEM agent which means that the extended attributes that are supposed to be applied to apps coming down from Intune wouldn’t be applied. When I use IntuneWin however, since the apps are pulled down and installed by the Intune MEM agent the correct attributes are added to all files added to disk during the installation.

2

u/dehin May 03 '22

That's very cool and definitely gives me some ideas as well! Thanks for elaborating.

1

u/[deleted] May 03 '22

Win32 apps have really cool things you can do with detection rules to make sure your scripts actually ran correctly, and report back to the console. The basic PowerShell scripts in Intune leave much to be desired.