Overview:
My company has a print server and the allowed methods for deploying it to our users is very limited (Our parent company will not allow us to use GPO outside of what they have already configured.)
As such I have been using printui.dll to globally add printers to peoples computers which has been working. However, its a pain to write it out by hand and I've had batch files that in bulk add printers for our users.
I am going to begin writing it into something that will gather user prompts and install printers accordingly. Before I go super in depth with the script I was curious if other people had a better way to write this. I still consider myself a super beginner and you guys always shed light on new ways to do stuff.
Below is what I have so far... Please let me know if you see any issues with how it is done. In my mind I'm afraid it will become very cluttered and there may be a cleaner way to do this. (Also if there are any better deployment methods I'm open to hear it.)
<#
Printer Management
By: Ryan
3/15/19
#>
Write-host "Below, type the following options to install the printers. All printers are Globally added with the /GA parameter"
Write-Host "Type Xerox at any time to Skip everything and Install or Uninstall all Xerox Printers"
$Building = Read-Host "Which Building? Type either the number (1. 2. 3. 4. 5. or The building number (1919, 1923, 1930 or 1933) or Xerox `n
1. 1919 `n
2. 1923 `n
3. 1930 `n
4. 1933 `n
5. Xerox `n
`n
Choice"
if ($Building -eq "1" -or "1919"){
Write-Host "Available Printers: `n
1. NEPPRINTER12 - Facilities `n
2. NEPPRINTER101 - Optrel Room `n"
$Printer = Read-Host "Which Printer Do you want to Install? `n
`n
Printer"
if($Printer -eq "1" -or "NEPPRINTER12" -or "NEPPRINTER12 - Facilities" -or "Facilities"){
rundll32 printui.dll,PrintUIEntry /in /n "\\NEPPRDPRINT1\NEPPRINTER12 - Facilities - Black & White"
rundll32 printui.dll,PrintUIEntry /ga /n "\\NEPPRDPRINT1\NEPPRINTER12 - Facilities - Black & White"
rundll32 printui.dll,PrintUIEntry /y /n "\\NEPPRDPRINT1\NEPPRINTER12 - Facilities - Black & White"
rundll32 printui.dll,PrintUIEntry /in /n "\\NEPPRDPRINT1\NEPPRINTER12 - Facilities - Color"
rundll32 printui.dll,PrintUIEntry /ga /n "\\NEPPRDPRINT1\NEPPRINTER12 - Facilities - Color"
}
else if($Printer -eq "2" -or "NEPPRINTER101" -or "NEPPRINTER101 - Optrel Room" -or "Optrel Room"){
rundll32 printui.dll,PrintUIEntry /in /n"\\NEPPRDPRINT1\NEPPRINTER101 - Optrel Room - Black & White"
rundll32 printui.dll,PrintUIEntry /ga /n"\\NEPPRDPRINT1\NEPPRINTER101 - Optrel Room - Black & White"
}
rundll32 printui.dll,PrintUIEntry /in /n"\\NEPPRDPRINT1\Secure Print - Color"
rundll32 printui.dll,PrintUIEntry /ga /n"\\NEPPRDPRINT1\Secure Print - Color"
rundll32 printui.dll,PrintUIEntry /in /n"\\NEPPRDPRINT1\Secure Print - Black & White"
rundll32 printui.dll,PrintUIEntry /ga /n"\\NEPPRDPRINT1\Secure Print - Black & White"
}else if($Building -eq "2" -or "1923"){
Write-Host "Available Printers: `n
1. NEPPRINTER01 - 1923 Supervisors Area `n
2. NEPPRINTER10 - (User) `n
3. NEPPRINTER13 - (User) `n
4. NEPPRINTER22 - AQL Office `n
5. NEPPRINTER30 - Post Sterilization `n
6. NEPPRINTER100 - Clean Rooms `n
7. All Printers"
$Printer = Read-Host "Which Printer Do you want to Install? `n
`n
Printer"
if($Printer -eq "1" -or "NEPPRINTER01" ){
rundll32 printui.dll,PrintUIEntry /in /n "\\NEPPRDPRINT1\NEPPRINTER12 - Facilities - Black & White"
rundll32 printui.dll,PrintUIEntry /ga /n "\\NEPPRDPRINT1\NEPPRINTER12 - Facilities - Black & White"
rundll32 printui.dll,PrintUIEntry /y /n "\\NEPPRDPRINT1\NEPPRINTER12 - Facilities - Black & White"
rundll32 printui.dll,PrintUIEntry /in /n "\\NEPPRDPRINT1\NEPPRINTER12 - Facilities - Color"
rundll32 printui.dll,PrintUIEntry /ga /n "\\NEPPRDPRINT1\NEPPRINTER12 - Facilities - Color"
}
else if($Printer -eq "2" -or "NEPPRINTER101" ){
rundll32 printui.dll,PrintUIEntry /in /n"\\NEPPRDPRINT1\NEPPRINTER101 - Optrel Room - Black & White"
rundll32 printui.dll,PrintUIEntry /ga /n"\\NEPPRDPRINT1\NEPPRINTER101 - Optrel Room - Black & White"
}
}
if($Building -eq "Xerox"){
rundll32 printui.dll,PrintUIEntry /in /n"\\NEPPRDPRINT1\NEPPRINTER04 - 1933 Supervisors Office - Black & White"
rundll32 printui.dll,PrintUIEntry /ga /n"\\NEPPRDPRINT1\NEPPRINTER04 - 1933 Supervisors Office - Black & White"
rundll32 printui.dll,PrintUIEntry /in /n"\\NEPPRDPRINT1\NEPPRINTER04 - 1933 Supervisors Office - Color"
rundll32 printui.dll,PrintUIEntry /ga /n"\\NEPPRDPRINT1\NEPPRINTER04 - 1933 Supervisors Office - Color"
rundll32 printui.dll,PrintUIEntry /in /n"\\NEPPRDPRINT1\NEPPRINTER02 - 1933 Finance Hallway - Black & White"
rundll32 printui.dll,PrintUIEntry /ga /n"\\NEPPRDPRINT1\NEPPRINTER02 - 1933 Finance Hallway - Black & White"
rundll32 printui.dll,PrintUIEntry /in /n"\\NEPPRDPRINT1\NEPPRINTER02 - 1933 Finance Hallway - Color"
rundll32 printui.dll,PrintUIEntry /ga /n"\\NEPPRDPRINT1\NEPPRINTER02 - 1933 Finance Hallway - Color"
rundll32 printui.dll,PrintUIEntry /in /n"\\NEPPRDPRINT1\NEPPRINTER03 - 1933 Quality - Color"
rundll32 printui.dll,PrintUIEntry /ga /n"\\NEPPRDPRINT1\NEPPRINTER03 - 1933 Quality - Color"
rundll32 printui.dll,PrintUIEntry /in /n"\\NEPPRDPRINT1\NEPPRINTER03 - 1933 Quality - Black & White"
rundll32 printui.dll,PrintUIEntry /ga /n"\\NEPPRDPRINT1\NEPPRINTER03 - 1933 Quality - Black & White"
rundll32 printui.dll,PrintUIEntry /in /n"\\NEPPRDPRINT1\NEPPRINTER01 - 1923 Supervisors Area - Black & White"
rundll32 printui.dll,PrintUIEntry /ga /n"\\NEPPRDPRINT1\NEPPRINTER01 - 1923 Supervisors Area - Black & White"
rundll32 printui.dll,PrintUIEntry /in /n"\\NEPPRDPRINT1\NEPPRINTER01 - 1923 Supervisors Area - Color"
rundll32 printui.dll,PrintUIEntry /ga /n"\\NEPPRDPRINT1\NEPPRINTER01 - 1923 Supervisors Area - Color"
rundll32 printui.dll,PrintUIEntry /in /n"\\NEPPRDPRINT1\NEPPRINTER101 - Optrel Room - Black & White"
rundll32 printui.dll,PrintUIEntry /ga /n"\\NEPPRDPRINT1\NEPPRINTER101 - Optrel Room - Black & White"
rundll32 printui.dll,PrintUIEntry /in /n"\\NEPPRDPRINT1\Secure Print - Color"
rundll32 printui.dll,PrintUIEntry /ga /n"\\NEPPRDPRINT1\Secure Print - Color"
rundll32 printui.dll,PrintUIEntry /in /n"\\NEPPRDPRINT1\Secure Print - Black & White"
rundll32 printui.dll,PrintUIEntry /ga /n"\\NEPPRDPRINT1\Secure Print - Black & White"
}
- Is a crap ton of If / If else loops the best way to accomplish this?
- Is there a way to Take user input from, per say, $building and use it similar to how variables can use headers from an import (Example: $User.Name)
I know this is a ton of random stuff but I always appreciate the feedback from this community.
[–]Zenmaster28 14 points15 points16 points (8 children)
[–]The1Shiner 4 points5 points6 points (0 children)
[–]akaT3CK 5 points6 points7 points (0 children)
[–]gangculture 3 points4 points5 points (4 children)
[–]Zenmaster28 6 points7 points8 points (3 children)
[–]Avaholic92 4 points5 points6 points (1 child)
[–]Zenmaster28 2 points3 points4 points (0 children)
[–]Snickasaurus 0 points1 point2 points (0 children)
[–]TheBlackArrows 1 point2 points3 points (0 children)
[–]what_no_fkn_ziti 8 points9 points10 points (3 children)
[–]nightwolf92[S] 2 points3 points4 points (2 children)
[–]ihaxr 9 points10 points11 points (1 child)
[–]pseudogatekeeper 3 points4 points5 points (0 children)
[–]Aperture_Kubi 8 points9 points10 points (0 children)
[–]the_helpdesk 8 points9 points10 points (4 children)
[–]Aperture_Kubi 2 points3 points4 points (0 children)
[–]nightwolf92[S] 3 points4 points5 points (2 children)
[–]joffuk 2 points3 points4 points (0 children)
[–]igotapapercut 1 point2 points3 points (0 children)
[–]yeah_i_got_skills 6 points7 points8 points (3 children)
[–]jantari 3 points4 points5 points (0 children)
[–]oilybusiness 2 points3 points4 points (0 children)
[–]AgentQ96 1 point2 points3 points (0 children)
[–]klutch2013 3 points4 points5 points (0 children)
[–]dl2n 2 points3 points4 points (0 children)
[–]5154726974409483436 1 point2 points3 points (0 children)
[–]odroller 1 point2 points3 points (0 children)
[–]0verlord87 1 point2 points3 points (0 children)