General, Powershell

Problem with Pending Reboot when using Desired State Configuration

On Knowledge Factory, the company I work for, every one get’s their own lab-server. Nothing fancy, but it helps a lot when I want to test something in a controlled environment.

I’ve been playing around a bit with desired state configuration on my lab server lately. And especially with the great module VirtualEngineLab which I’ve been using to automatically build various scenarios. Each time I start a new build, the module uses the DSC resource xPendingReboot to check for pending reboots.

I got constant warnings about pending reboots and was advised to reboot my host before trying again. I didn’t understand why I would need to reboot so I looked in to the resource and realized that my server had “PendingFileRename”-actions in the folder C:Windowssystem32spool. Now that’s strange, my lab server doesn’t even have a printer. Or does it?

It turns out that I’ve been sloppy and brought my clients local printers with me to the RDP session. Each time new printer drivers were installed it caused a pending file rename operation. To make sure this won’t happen again, I’ll disable the possibility to bring local printers to the server, also known as client printer redirection.

This can be done in one of two ways, either by GPO or by a setting in the registry. I chose to use the registry, and of course I used PowerShell to change the setting by this one-liner:

Setting a registry value is not really a valid option if you have hundreds of servers in a domain, then the GPO approach is the way to go. In Windows Server 2012 R2 the setting can be found in: Computer Configuration –> Administrative Templates –> Windows Components –> Remote Desktop Services –> Remote Desktop Session Host -> Printer Redirection > Do not allow client printer redirection

If you’re interested in knowing more about the VirtualLabEnging module and how to use it, Iain held a great session at PowerShell Summit Europe which is available on YouTube: https://www.youtube.com/watch?v=jefhLaJsG3E

The code Iain is using in the session is available on GitHub: https://github.com/iainbrighton/PSHSummit-Man-vs-Testlab