Print Server using Windows Server Core

Introduction

Many administrators are always looking for ways to simplify the required management of their environments, save on overhead, resources, etc. With the advent of Windows PowerShell and it growing to be a commonplace administrator utility in Windows environments, simple systems such as print servers no longer really require a full-fledged graphical user interface. Print servers are prime candidates to be hosted on the CLI-based Windows Server Core variant of Windows Server, especially where they are so easily managed through remote PowerShell. In this brief article, we’ll take a quick look at spinning up a core print server and some of the options available for administering the new server.

Spinning up your machine

Whether you are using traditional hardware for your server (a rackmount server, blade server,tower server/desktop PC) or a virtualized environment, you’ll first need to actually install Windows Server Core on your machine. For my environment, I spun up a virtual machine in my Proxmox virtual environment, but many may be using VMware, Hyper-V, or other solutions which will work perfectly fine.

Adding the features and roles to the server

Once you have Windows installed and your requisite network and domain configuration done, add the necessary services and features to the server:

Install-WindowsFeature Print-Services

This will install the Print Services role as well as the Print Server Role Service. No further configuration is necessary as far as the services and features go. All that is left to do is add some printers!

Administering the server

There are multiple ways to administer your new Windows Core print server.

PowerShell

Arguably the correct way to manage a Windows Core server, is PowerShell. Like other deployments, a print server is managable through the command line with general ease. Beginning with Server 2012’s Core version, there are many print management commands available to administrators.

As an example, we can configure a printer using just two commands:

Adding the printer port: Add-PrinterPort -Name "192.168.254.5" -PrinterHostAddress "192.168.254.5"

Adding, sharing, and publishing the printer: Add-Printer -Name YourPrinter01 -DriverName "HP Universal Print Driver PCL6" -PortName 192.168.254.5 -Shared -ShareName "YourPrinter01" -Published

VBS

An archaic option also exists. At C:\Windows\System32\Printing_Admin_Scripts you’ll find a variety of VBS scripts that can be used to administer the print server. But seriously, who is preferring VBS when we have PowerShell?

As an example, we can configure a printer using the following commands:

Creating the printer port: cscript prnport.vbs -a -r 192.168.254.5 -h 192.168.254.5 -o raw

Adding a printer on the above printer port: cscript prnmngr.vbs -a -p YourPrinter01 -m "HP Universal Print Driver PCL6" -r 192.168.254.5

Sharing the above printer: cscript prncnfg.vbs -t -p YourPrinter01 -r 192.168.254.5 -h YourPrinter01 +shared -direct -m "Default printer for HR" -l "YourDesiredLocation"

Publishing the printer to Active Directory: cscript pubprn.vbs \\printserver\YourPrinter01 "LDAP://CN=YourContainer,DC=YourDomain,DC=com"

GUI

If you really just can’t let go of using the graphical user interface just yet as you ease into command-line-based administration you can still get your hands on the GUI by executing: C:\Windows\System32\printui.exe /il

Additionally, on a remote machine, you can connect RSAT to your Windows Core print server and use the Print Management snap-in for the Microsoft Management Console to visually administer the print server.

But seriously…get comfortable with PowerShell. This is the way.

Conclusion

And, well, that’s pretty much it. There is certainly a more granular level of detail we could go into, but for the purposes of a general overview, I think that does it. Windows Core servers are quick and easy to spin up and an absolute breeze to configure if you are comfortable with PowerShell. In a lab environment, they can also be a great way to get more comfortable with PowerShell if you are just learning. Go ahead and spin up a Windows Core server in VirtualBox or your choice of virtualization bench and give it a try!

What are you using core servers for in your environment, and how do you like it? I’d love to hear from you in the comments below.


Additional Reading

Install Print and Document Services | Microsoft Docs

Using Server Core as a Print Server – Microsoft Tech Community

Using PowerShell to Add a Network Printer for All Users of a Computer

Purpose

This brief article details the commands necessary to use PowerShell to add/install/map a network printer for all users of a computer.

Prerequisites

The below actions require the executing user to have administrative rights to the workstation in question.

Solution

Establish a Remote PowerShell session

In an elevated PowerShell session (running as administrator), run the following command;

Enter-PsSession -ComputerName HOSTNAME.FQDN

where HOSTNAME.FQDN is the fully-qualified domain name of the workstation in question.

Example: desktop01.yourdomain.com

You can actually execute this process using the short name of the computer instead of the FQDN.

Remove the network printer for all users

Once you’ve entered the remote PowerShell session successfully, run the following commands in sequence;

RUNDLL32 PRINTUI.DLL,PrintUIEntry /ga /n\\PRINTSERVER\Shared-printer

where PRINTSERVER is the NETBIOS name of your print server from which the printer is shared and Shared-printer is the shared name of the printer you’d like to add/install/map.

When this is complete, the network printer should be uninstalled/removed for all users on that workstation. This can be verified by having users logon and check their Devices and Printers window.

Using PowerShell to Remove a Network Printer for All Users of a Computer

Purpose

This brief article details the commands necessary to use PowerShell to remove a network printer for all users of a computer.

Prerequisites

The below actions require the executing user to be an administrator of the remote workstation, or a Domain Administrator.

Solution

Establish a Remote PowerShell session

In an elevated PowerShell session (running as administrator), run the following command;

Enter-PsSession -ComputerName HOSTNAME.FQDN

where HOSTNAME.FQDN is the fully-qualified domain name of the workstation in question.

Example: desktop01.yourdomain.com

You can actually perform these commands without using the FQDN, and using the short name instead.

Remove the network printer for all users

Once you’ve entered the remote PowerShell session successfully, run the following commands in sequence;

Get-WmiObject -Class Win32_Printer | where{$_.Name -eq ‘\\PRINTSERVER\Shared-printer‘}

where PRINTSERVER is the NETBIOS name of your print server from which the printer is shared and Shared-printer is the shared name of the printer you’d like to remove. This command will return the printer that you’d like to remove, if it is installed for the user running the command. Even if the user running the command does not have this printer installed, this process will still work as intended.

Get-WmiObject -Class Win32_Printer | where{$_.Name -eq ‘\\PRINTSERVER\Shared-printer‘}| foreach{$_.delete()}

again, where PRINTSERVER is the NETBIOS name of your print server from which the printer is shared and Shared-printer is the shared name of the printer you’d like to remove.

When this is complete, the network printer should be uninstalled/removed for all users on that workstation. This can be verified by having users logon and check their Devices and Printers window.

Keeping your software up-to-date the easy way

Get rid of annoying “update available” notification and pop-ups by having your computer take care of application updates automatically.

Introduction

Don’t you love those pop-ups you get in the corner of your desktop telling you there’s an update for a program installed on your computer? Or how about when you open a program and it tells you there’s an update? You just want to use your software, so if you’re like me, you’ve probably clicked “ignore” or closed the update to just get to what you were doing. But there is a better way! Nobody wants to take the time to keep all of their software up-to-date. In this brief blog post, I take a look at how you can make this happen “auto-magically,” at least for many common programs.

Installing Chocolatey package manager

The first thing we will need to do is install the Chocolatey package manager. This is going to let us have access to one central source for the programs and their updates.

To install Chocolatey, open Windows PowerShell by going to the Start Menu and typing “powershell” (quotes ommitted). Right-click the top result, and click “Run as Administrator.” This will require you to have administrative rights. If you do not have administrative rights, this process will not be possible.

In the Windows PowerShell window that appears, paste the following command:

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

Once that command has completed, close Windows PowerShell and launch it again with administrative rights like we just did.

Installing packages

Now we need to install the packages that we want to keep up-to-date. To find out if a program you have has a package available, use the below example in PowerShell:

choco search programname

where programname is the name of the program you want. Some examples might be:

  • adobereader
  • adobe-connect
  • googlechrome
  • microsoft-edge
  • discord
  • putty
  • icue
  • bitwarden
  • lastpass
  • obs-studio
  • conemu
  • forticlientvpn
  • openvpn
  • java
  • jre
  • logitech-options
  • reflect-free
  • and many, many more.

To actually install any or a combination of these, use the following command:

cinst programname -Y

where programname is the package name. You can list multiple package names in succession to install multiple programs at once:

cinst programname1 programname2 programname3 -Y

Chocolatey will download the packages and install them.

Writing the update script

With the packages installed, now we need to create a super simple script that will update those packages.

Open Notepad by going to the Start Menu and typing “notepad” (quotations omitted) and running the top result.

In the blank document that opens, type the following:

choco upgrade all -Y

If you continually run into errors with certain packages updating and don’t mind the insecurity of it, you can also use:

choco upgrade all -Y --ignore-checksums

though I don’t recommend it.

Now save this by going to File > Save As… In the Save As window, change the drop-down menu for the file type. It will be defaulted to .txt and we want to change it to All Files. Type a name for the file ending with .ps1. Example:

chocolatey-updater.ps1

Save it to a location where it won’t be touched and will always be available. I have mine saved to a folder I created at C:\ScheduledTasks but you can put yours wherever you want.

Scheduling automatic updates

Finally, now that we have installed packages and created a script to update them, we will want to schedule the update process to be completely automatic. Because being hands-off is the whole point!

Open the Task Scheduler by clicking the Start Menu and typing “task scheduler” then running the top result.

In the resulting Task Scheduler window, open the Action menu, then click Create Task.

Give your scheduled task a name and a description, then select “Run whether user is logged in or not” and check “Run with highest privileges.” Finally, Configure for: Windows 10.

Move to the Triggers tab.

Add a new trigger to begin the task on a schedule. Input your desired start date, reoccurence period, and ensure “Enabled” is checked, then click OK.

Move to the Actions tab.

Make the action “Start a program” and in the Program/script field, paste the path to PowerShell:

%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe

In the Add arguments field, add the following:

-file scriptpath

where scriptpath is the path to where you saved your script earlier. My example looked like this:

-file C:\ScheduledTasks\chocolatey-updates.ps1

When done, click OK on all remaining Task Scheduler windows and the task will be scheduled. Now, as long as your computer is on, you leave the task scheduled, and the script is available where you saved it, your computer should automatically update your specified programs without you having to do anything at all.

I have been keeping my computers up to date like this for several years (set to automatically update everything weekly) and it saves me tons of time, and I rarely get notifications about new versions or annoying popups anymore.

Bringing it all together

In this process, we installed Chocolately package manager, figured out what programs we wanted to keep up to date that were available through Chocolatey, installed those programs, wrote the update script/command, and scheduled PowerShell to run that command at a regular interval.

How did this go for you? Got any other neat tips and tricks for keeping your system running in great shape? I’d love for you to share them in the comments.