Archive | Windows Server

Windows Server 2012 & Features on Demand

If you’re anything like me, typing at a keyboard all day is about all the exercise you get.  I’ll admit it, over the last couple months I’ve packed on a couple pounds.  I just told myself, woman love the stellar I.T. body look.  A gut almost touching the edge of the desk, the hump in the back from bending over the keyboard all day.  The none stop drinking of caffeinated soda.  So how’s a guy like me suppose to drop some weight?  Exercise!  Ha, yeah that’s not going to happen, but I wonder how much liposuction costs?

It’s easy for humans, hook up a hose, and suck out all the fat.  But what about your servers?  Gigs, and gigs of data are taking up hard drive space, and as time goes by, the plumper your server will become.  Soon you’ll be left with barely any free space.  Now what if I told you there is something you can do?  A sort of liposuction for your server.  Thanks to Windows Server 2012 Features on Demand , it’s now possible.

With Windows Server, we have what’s called the WinSxS (Windows Side By Side) folder.   This folder is located in the Windows directory.  (C:\Windows\WinSxS)  The folder contains all the files that are required for a Windows installation of a feature or role.  The advantage of this folder is you can install a role, or enable a feature without the source media.  The disadvantage of this folder is, it makes your server fat!  I’m talking Gigabytes of data just sitting there waiting for the day you install a new role.  But what if that day never comes?  All that good hard drive space going to waste.  Luckily with Windows Server 2012 you can now reclaim that space with PowerShell.

Features on Demand

In Windows Server 2012, you can minimize the footprint of your installation by uninstalling the files from your WinSxS folder.  This ability is called Features on Demand.  The only catch is, if you ever would want to install a feature you removed, then you would need to access the Windows Server 2012 source files.  Okay, lets put our server on a diet.

It’s a fairly simple process to uninstall these roles or features files from disk.

1. Open Windows PowerShell as Administrator.

2. Type the following: Uninstall-WindowsFeature –Name <feature_name> –Remove

3. That’s it!

Okay so for example I would run the following command to remove DHCP WinSxS files.

 Uninstall-WindowsFeature –Name DHCP –Remove 

image

Run the following, if you would like to remove all the role and feature files that currently are not installed on the local server.

 Get-WindowsFeature | Where-Object -FilterScript { $_.Installed -Eq $FALSE } | Uninstall-WindowsFeature –Remove 

image

Don’t worry, you can reinstall these feature files at any point.  To do so, run the following PowerShell command.

 Install-WindowsFeature <featurename> -Source wim:<path>:<index> 

How do you know what index number to use?  Simple.

 Get-windowsimage –imagepath <path to wim>\sources\install.wim 

image

I’m running Windows Server 2012 Datacenter, so I selected “index 4”.  Now if I wanted to reinstall DHCP onto this server I would type the following command:

 Install-WindowsFeature DHCP -Source wim:d:\sources\install.wim:4 

image

You can alternatively reinstall a feature by using Server Manager. Run the Add Roles and Features Wizard, select what you want to install, and then at the Confirmation screen “specify an alternate source path”.

image

The –Source option can access the files in there different ways.

  1. Searching the location you specified during either your PowerShell command or during the Wizard.
  2. Group Policy Settings: Computer Configuration\Administrative Templates\System\Specify settings for optional component installation and component repair.
  3. Searching Windows Update

Create a Feature File Store

Before we end, I would also recommend setting up a feature file store.  Instead of searching for the media disk, just copy the Sources\SxS folder from your Windows Server 2012 installation media to a network share.  For example, \\network\share\sxs.  Then when you want to reinstall a feature, just point the –Source to your new network share.

Hopefully you now have a leaner server.  Man, all this weight lost talk has gotten me hungry.  I think its time for a Baconator!

Searching for a Windows Update

waldoWhen I was a kid, I use to love the “Where’s Waldo?” books.  If you were a child of the 80’s or 90’s, then I’m sure you had a couple of these books on your self as well.  Each page contained hundreds of cartoon characters doing a variety of entertaining things.  Your job was to search the pages looking for a man wearing a red-and-white-striped shirt, bobble hat, and glasses.  Yes, Waldo had style.

In the beginning of the book, Waldo was easy to find.  However as the book went on, trying to find Waldo was a huge challenge.  I remember at the end of one book, they dressed every character in the same red-and-white-striped shirt.  I hated that page!  It took forever to find him.

So why I’m I rambling about Waldo?  Well in our adult IT Careers, we have the same challenges when it comes to Windows Updates.  How many times have you been asked, “Is update something something whatever installed on server who cares”?  You then answer with, I don’t know let me look.  Then it’s a trip to the Start, Control Panel, Add or Remove Programs, (Programs & Features with 2008+), View Installed Updates.  Finally then, you get to search for Waldo, I mean the update.  And just like the book, in the beginning updates are easy to find with a new server.  However the longer you have the server, the harder it becomes.

So what can be done to speed up the process?  Well you have a couple choices.

If your on a Windows 2003 server you can run the following command.

 dir /ad %systemroot%\*KB2503665* 

You would change “*KB2503665*”  to whatever update you are looking for.  This will work as long as you didn’t delete the uninstall folder.  You should see the results below if the update is installed.

image

You could also just run the command without the “d” switch and pull the log file as well.

 dir /a %systemroot%\*KB2503665* 

image

Okay, that is great if we were living in the year 2003, but it’s 2013, and we now can harness the power of PowerShell.  All you have to do now is open up your PowerShell prompt and type Get-HotFix and the update your looking for.

 Get-HotFix –ID KB2488113 

image

You could even leave off the “-id” switch and it will still work.

The great thing about this command is, you can search not only for the Hot Fix ID, but for the description, who installed it, or when it was installed.

 Get-HotFix | where { $_.installedon -eq "5/9/2012"} 

image

On top of that, you can scan multiple computers.

  Get-HotFix -id KB2488113 -ComputerName ADDC03, ADDC04 

image

Before we go in further with the Get-HotFix cmdlet, I do have to warn you about one catch.  Since the introduction of Windows Vista, this cmdlet only returns updates supplied by Component Based Servicing (CBS).  This is due to the Get-HotFix cmdlet using the Win32_QuickFixEngineering WMI Class.  These updates are also not listed in the registry.

It also means any update installed by the Microsoft Windows Installer (MSI) or the Windows update site (http://update.microsoft.com) are not returned by this cmdlet.  “What Up with That?”  Instead to view everything, you will need to use a combination of the Get-Hotfix and something like the two commands below.  


$Installed = "hklm:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall","hklm:\software\microsoft\windows\currentversion\uninstall"

Get-ChildItem $Installed | ForEach-Object {Get-ItemProperty $_.pspath} | select DisplayName

image

Running the extra two commands will scan your registry, and give you a list of everything installed on your computer.  You can then manipulate the data to your liking.  Create reports to show Service Packs, Installed updates, Office Updates, or even applications that are installed.

Simple right?

Well this article isn’t ground breaking by any means, but if it saves you some time, and gets you out of the office a little earlier on a Friday afternoon, then I think I’ve done my job.  Maybe you will even have time to look through that old Where’s Waldo book again!  Nah…Go get a beer instead, you deserve it!