Out with the Windows.old

over-the-hill Over the last few days I’ve started the process of upgrading my test virtual machines to Windows Server 2012 R2, or in the case of my mini Hyper-V server, to the final bits of Windows Hyper-V Server 2012 R2. In many cases I had been running the preview bits. I know I probably should have done clean installs, but I decided to upgrade in-place. The upgrade itself is easy and quick. However, the upgrade comes with a price.

The upgrade process will leave a folder called Windows.old which essentially contains files from the previous installation. As you might expect this file can take up a lot of space. Unfortunately, you can’t simply delete the folder as many of the files and folders have special permissions and owners. If you search, you’ll find a number of articles that explain the proper way to remove this folder is to use the disk clean up wizard or the Cleanmgr.exe command line tool. But some of my systems are running Server Core which means no GUI for the clean up wizard and no command line tool. Eventually I came across this solution.

His solution requires junction.exe from the Sysinternals website. His solution was also a mix of PowerShell and CMD commands. I decided this could all be done with PowerShell, plus I could take advantage of ShouldProcess so the script supports -WhatIf.

You will need to make sure junction.exe is somewhere in your path. I put a copy C:\Windows. I’ve used this a few times and it works pretty well. You will probably get prompted to continue and it will take a few minutes to run. But it gets the job done when other options are not available. I hope you’ll let me know how it works for you, but please test in a virtual environment where you can roll back and/or make sure you have a verified backup.

Mini Hyper-V: Operating System

When we left my project, the new mini server had booted up using Windows Hyper-V Server 2012 R2. This is a server core installation intended to only run Hyper-V, which is perfect for my needs. The server booted up with a temporary name and a DHCP assigned IP address. The next step is configure the server and join it to my test domain.

I could do this all interactively using the sconfig script, but where’s the challenge in that! So I’m going to configure the server from a Windows 8 client with RSAT installed in my target domain. There are ways to configure Hyper-V in workgroup environment but I want to take advantage of domain. It shouldn’t really make any difference but my test domain, Globomantics.local, is running in a Hyper-V environment on my Windows 8 laptop. My mini Hyper-V server will belong to this domain, as will any virtual machines it ends up hosting.

To get started I know the IP address of the new server and credentials for the local administrator account. With this I can use PowerShell remoting, since it is enabled by default in Windows Server 2012. However, on my client, I need to temporarily add the host to the TrustedHosts list. Otherwise, the client won’t trust the server and I won’t be able to connect. In an elevated I’ll run this command.

Using -Force suppresses confirmation prompts. This setting will allow me to connect to any host using an IP address that starts with 172.16. I should now be able to use Invoke-Command or run any configuration workflows. In fact, I’m going to use some basic workflows to set the computer name and IP configuration. First, I’ll verify remote connectivity.

Looks good. Next, I’ll define some PowerShell variables to use with my workflows.

The first workflow I want to run will perform some basic configuration.

Once this workflow is loaded into my session I can run it and configure the new server.

Next, I want to configure the IP configuration. The new server only has a single NIC which simplifies matters a great deal. Here’s the workflow I’m going to use.

To execute, I’ll splat a hashtable of parameters to it.

One caveat here is that when you change the IP address you’ll lose your connection to the remote computer. PowerShell will keep retrying. What I probably should have done was to include some parameters to limit the retry count. Eventually, the command will timeout and I can continue.

Next, I want to rename the computer and join it to the domain.

Again, I’ll splat a hashtable of parameters, this time connecting to the new IP address.

Eventually the computer will reboot and I’ll get a positive result.

Set-CompConfigWorkflow

Excellent. Now that the server has rebooted it belongs to the domain and I can use the new name to verify a few things.

chi-hvr2-newip

I used the new server’s FQDN for the CIMSession name as I couldn’t get the NETBIOS name to work. Probably because I didn’t wait long enough for browser stats to get updated. Anyway, it works and I can also verify Hyper-V is working.

chi-vhr2-vmhost

The last thing I should do is remove the trusted hosts settings on the client. But because I trust my network and I might need to do this again, I think I’ll leave it for now. But I did it! I now have a Hyper-V server ready for me to use.

Mini Hyper-V: Setup

Now that hardware has been installed on my mini Hyper-V project, next up is to setup the unit and get software installed. The Brix fires up very quickly and of course since nothing is installed I initially see the no operating system found message. Rebooting, pressing F2 gets me into the BIOS setup.

IMG_6536

The only thing I need to do on the first page is to adjust the date and time. I was hoping I could change the Project name to something such as Mini Hyper-V, but it doesn’t appear that is possible. On the Advanced tab, I’ll want to enable virtualization.

IMG_6537

You can see the Brix has a dual-core i7 processor. On the Advanced tab I can also verify the mSATA drive.

IMG_6538

Checking boot options I see that the unit only sees the internal drive.

IMG_6539

But the device supports EEFI and legacy boot options so I’m not expecting any problems. After saving my changes I even verified that F12 will bring up a boot menu, should I need it.

Next I need an operating system. I decided to try preview of Windows Server 2012 Hyper-V R2. I realize I’ll need to re-install when it is finally released. I don’t expect to run anything other than Hyper-V on this little box and Server Core keeps the footprint nice and small. But how do I get it onto the unit? Easy. I need to “burn” the ISO to a USB stick. To do that I’ll use the freeware, ISO to USB.

One thing I messed up initially, not really thinking, is that you need a decent size USB device. I foolishly started with 2GB only to realize I need at least a 4GB device.

ISOtoUSB

The utility will reformat the USB device. The one I was using had some pre-existing files and I had to try a couple of times to get the process to work. I think the best approach is to delete any files first, or even “pre-format” the device first. But once I got through that hurdle after about 7 minutes I had a bootable USB device which I inserted into the Brix and fired up.

The unit immediately detected the USB device and started the installation process.

IMG_6541

Excellent. I selected a custom install.

IMG_6542

By the way, I’m installing without a mouse but the keyboard shortcuts are more than sufficient. Install is very speedy. Copying the install files too literally seconds. Of course I’m installing Server Core but still very impressive.

IMG_6543

The overall installation took less than 3 minutes. Reboots are blazingly fast. Within minutes I had the initial screen to change the admin password.

IMG_6544

After struggling to get a password typed on my super mini keyboard, I’m eventually rewarded with the Server Core setup windows.

IMG_6545

I was wondering if I would need to load any drivers off the CD that came with the Brix, but so far I haven’t seen a need. I notice an occasional ripple in the video, but that could be an artifact from the ancient Dell monitor I’m using or the adapter. In any event it’s no big deal since once this is setup it is going to run headless anyway. The server got a DHCP address which is the most important element so I should be ready to start configuring the OS. I’ll cover that in the next post.