Tip of the Week 5 – When sfc fails, DISM prevails

In the last month or so, I have come across a number of servers where the only possible cause remaining for the “issues” is file system/OS corruption. This has been across various scenarios; Cloud hosted, on premise physical, on site virtualised etc. and each time the obvious Googleable thing to try is a sfc /scannow.

For those who do not know this command, it is an old, old, old Windows built in tool designed to scan and repair corruption within Windows itself, notable directories such as System32. File system corruption can occur for many reasons, a dodgy build of the OS to start with, Windows Update issues, potentially caused even by viruses, or remnants of. So the cool thing about running sfc /scannow (from an elevated Command Prompt), is that it is has been around since Windows 98 – incidentally my first OS on a PC that was solely mine!

So sure, I have run this many times, probably more than a hundred, but recently on more advanced operating systems such as 2012R2 and 2016, I have seen it failing a little. Usually the result of the scan states

“Windows Resource Protection found corrupt files but was unable to fix some of them

Details are included in the CBS.Log windir\Logs\CBS\CBS.Log.”

So if you see this does it mean your system is totally broken…


All is not lost


If you have seen my previous posts on DISM you will know it is great for keeping a system tidy, especially when it comes to Windows Updates and the bits they leave behind. However, did you know that DISM could also be used to repair the file system? – Well no, neither did I until this year!

There are a couple of commands very useful to try, when a sfc fails:

  • DISM /Online /Cleanup-Image /CheckHealth

    This checks for corruption without attempting repair

  • DISM /Online /Cleanup-Image /ScanHealth

    This checks for Windows Image corruption and takes significantly longer than a CheckHealth

  • DISM /Online /Cleanup-Image /RestoreHealth

    BINGO! – this one will actually attempt the repair of a corrupted filesystem, and from experience means an sfc /scannnow will also complete without errors.



Please note I am not saying this is the solution to all file system/OS corruption, what I’m saying is in the last few weeks it has saved 3 servers from being binned!


So yet again, system maintenance via the DISM tool is a winner, whether keeping it tidy or just in one piece.


Few things to cover…

Firstly, thank you for stopping by, taking time to view my blog, read my posts and hopefully take something away from them.

If you do happen to like the posts on here, then please do say so; retweet, Facebook share, LinkedIn, whatever, it would be great to get more of my content out there, and more of you on here!

Also If you have any post requests or tech questions, please send those over too, Twitter is possibly the best for that @jaward916

Secondly, apologies for the lack of posts during February. Over the Christmas break I had some good ideas which I made lots of notes for then came up with the 4 posts during Januray, however the ideas have dried up (already) and family related things have meant less free weekends. The weekday’s are taken up with the job, typically Sundays are when I get “me” time to do some techy stuff for my benfit rather than for customers!


Whilst I don’t have a nice full topic to write up for this week (I promise there are some ideas bouncing around in my head) what I do have is a snippet of 2018 so far in my world of tech/code/software etc.

During January I spent many hours getting to grips with a new major release of the software I work with, as I’m a little bit of a nerd, a lot of those hours were spent in my own time, drilling down into things, working scenarios out, deplyoment strategies etc. What I ended up with by last week was a full test scenario, remeniscient of a real world deployment. Effectivley emulating what a customer would have. The really cool thing is this allows me to very quickly test out scenarios, when a customer reports something “not working” I can run it through my servers and give them an answer same day along the lines of (usually) “try this, I think you’ve done X in the wrong place”. This is in no way a bypass to my wonderful colleagues in Support, but more of a way to assist the customer with getting their deployment up and running. I don’t generally delve into the applications, I’m not that kind of consultant. What I do is design deployments and implement them, I get the back end of a system up and running. The latest version included quite a few new technical enhancements, so getting experienced with them is an essential part of me being able to do my job!

February hasseen a few more interesting engagements for me, site visits all over the place (on top of delivering 2 training courses during January), with some more lined up, possibly even abroad.

What I am being asked to do now is anlyse, review, and in some cases redesign or reimplement deployments. Not because what they have was done wrong to start with, far from it, but more to help them become future-proof, employ best practices and become more agile as the world around us is changing, and the software adjusts to match. There’s no wheel reinvention, just a set of new tyres here and a bit of air there.

I write on here a lot about SQL Server as it is the underlying DB server platform for all systems I support. Another area of SQL that has always interested me is SSRS (SQL Server Reporting Services), basically a very smart, sometimes fiddly report generation toolset. What I have been able to do over the last few weeks is take some reports, rip them apart, analyse a few minor but irritating issues and develop solutoins to those problems. The strange thing is that I’ve not been trained in SSRS, or had the change do do anything with it prior ot this. I just saw an issue, delved straight into the SSRS builder and worked it out, for myself. I forgot I had those abillites and it’s been refreshing to remember how good I used to be solving new problems.

I’m thinking some SSRS tips in a post may be some decent content in the future, think I’ll build the scrapbook up on those!


That’s it for an update, I’ve also updated the About page on this site to reflect the last 2 years!


Tip of the Week 4 – DISM Cleanups

In the last post I covered DISM for the purpose of changing/upgrading the version of Windows, and we found that the DISM tool has existed since 2008, however in 2012R2 they added much improved, usable functionality. Did you know DISM is also responsible for things such as Windows updates?

Under the hood DISM is the tooling being used to install and maintain those wonderful Windows Updates you get every month on Patch Tuesday (is that still a thing?) Which also means we can use the toolset to also tidy up afterwards. Remember Disk Clean up (cleanmgr)? Well it’s a nicer CLI version of the Updates clean-up in there.

There are 3 levels of update clean up via DISM

  • Component Clean up – this cleans up updated components i.e. removing the packages used to install the updates
  • Reset Base – same as above, but means all deletes all superseded versions of every component in the component store, meaning you won’t be able to uninstall service packs/updates applied before this point in time
  • SPSuperseded – removes all backup components needed to uninstall the service pack, also you cannot remove the service pack anymore after using this command.

In short doing 2 and 3 will free up more space but makes rolling back very difficult, option 1 is a nice way to keep the system tidy:

Example on Windows Server 2012R2

  • Disk is at 37.1GB free after being fully updated and having key applications installed

  • Component cleanup is run and takes quite a while… (I had to go out and check 3 hours later, suspect it took ~1 hour)

  • Following the cleanup run we can see around 7GB has been freed up on the system

From this quick demonstration above it’s clear to see that significant disk space is used up by irrelevant, outdated files. The only reason to keep these is if you want to remove an update and reapply later, but surely not all 7GB worth…

I’ve started using the dism cleanup commands during my build process, so that before I start using a server in anger, I get it to as clean a state as possible, fully updated but tidy!

The full commands for DISM cleanup are:

  • dism /online /Cleanup-Image /StartComponentCleanup
  • dism /online /Cleanup-Image /StartComponentCleanup /ResetBase
  • dism /online /Cleanup-Image /SPSuperseded

Tip of the Week 3 – Converting Server Eval to full version

NOTE: You will require a valid Windows Server product key for this to work, this is in no way intended as a workaround to legitimate licensing.

Sometimes when just messing around with an idea or trying to prove a concept out you may find yourself quickly downloading an ISO from Microsoft for whatever OS version you’re testing on. Perhaps you haven’t got access to your usual ISO library or forgot credentials for your Volume Licensing portal etc.

The only issue with the TechNet downloads is that they are Evaluation editions, this means that within a certain number of days (usually 60 or 180 depending on version) you will not be licensed, activated or legit… slight problem here is that within 180 days you’ve probably built your best dev/test platform in years and don’t want to lose it, in fact you want to move it to your production servers, keeping it and maintaining it for eternity. Do you build a new VM with the proper ISO and Product key?

The answer is no, just upgrade your edition.

A while ago now, Microsoft introduced DISM (Deployment Image Servicing and Management tool) – a handy suite of command line tools for managing such situations. So how do I convert from evaluation to Server Standard or Datacenter editions, and what versions of Windows Server does this work with?

  1. Open Command Prompt as Administrator
  2. Open PowerShell as Administrator – it’s the 21st Century
  3. Run the following command:

    dism /Online /Get-CurrentEdition

  4. The image above shows I’m running Version 10 (Server 2016) and I’m on a Server Standard license, therefore not Eval. However if you were on an Evaluation license it would say ServerStandardEval
  5. In order to upgrade the license to a full version, or to go from Server Standard to Datacenter edition you can run the following:

    DISM /online /Set-Edition:<edition ID> /ProductKey:XXXXX-XXXXX-XXXXX-XXXXX-XXXXX /AcceptEula

    The <edition ID> will be either ServerStandard or ServerDatacenter

  6. The ProductKey is the bit unique to you/ your company, however, if you use KMS keys you can obtain these from the following page: https://docs.microsoft.com/en-us/windows-server/get-started/kmsclientkeys – I won’t go into the KMS vs. MAK conversation here but feel free to Google it to work out which you have/need.
  7. Here’s an example I ran using a KMS key:

    Note it removes the “package” of the one installed and replaces it with the one you’re putting in, A reboot will also be necessary.

For more info regarding DISM go here: https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/what-is-dism

DISM has been around since Windows 7/ Server 2008 but it’s been most useful since 2012R2 onwards, I will be posting some additional DISM tips in the next post!


Oops I missed a week…

Apologies for no post last week, whilst I had built up some content over the Christmas break I hadn’t had the time to write any content this month, until now.

Sometimes life gets in the way, and Family always comes first for me, so now things are improving the content should flow again.

As a thanks for sticking around I’ll have 2 posts on here tomorrow for you!

Tip of the Week 2 – SQL Versions & EOL

Have you ever wondered whether you’re definitely on the latest patch of SQL?

I found a site a few years ago which I use at least once a week, every week.

In SSMS when you view a server’s properties you will see a version number e.g. 11.0.5058.0 which to most of us doesn’t mean a lot. On the face of it you can tell its v11 of the software, and you suspect it’s not the GA release due to the 5058 part, but in reality how does this translate to the year and service pack?

The answer is: http://sqlserverbuilds.blogspot.co.uk/ which provides a nice little table as below.

The best thing is that this site seems to be kept up to date all the time and further down the page you will see all sub-versions/ Cumulative updates and release dates, with hyperlinks to release notes.

I find this info very useful when debugging performance issues, especially with 2008R2/2012 so I can check the customer is on the latest patch of the version they have. Also with Microsoft’s changes to extended life of these products over the last few years, some patches are supported and others aren’t. To check what is/isn’t supported it’s worth browsing (and bookmarking) this link: https://support.microsoft.com/en-us/lifecycle/search/

The Product Lifecycle page at Microsoft is fully searchable for all MS products, and will tell you which patches are supported and which ones may already be out of support. e.g. for SQL Server 2012 you’re fine if on SP4, for SP3 you only have 8 months left, SP2 down is already out of support:

If you ask me we should all be on SQL 2016, but I fully understand the reasons we hold back, whether due to licensing costs, downtime issues, 3rd party support or other issues.