Tuesday, 9 July 2013

get-windowsfeature : The given key was not present in the dictionary

When you run the get-windowsfeature cmdlet in PowerShell on Windows Server 2012 you may see the following error

get-windowsfeature : The given key was not present in the dictionary.

At line:1 char:1
+ get-windowsfeature
+ ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-WindowsFeature], KeyNotFoundException
    + FullyQualifiedErrorId : System.Collections.Generic.KeyNotFoundException,Microsoft.Windows.ServerManager.Commands
   .GetWindowsFeatureCommand

This seems to occur if there is a problem in the following registry key
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ServerManager\ServicingStorage\ServerComponentCache

As this is just a cache registry key you can try renaming the key to ServerComponentCache.old and then re-running the PowerShell command or refreshing the view in server manager.

This recreates the key and rebuilds the server feature information.


Network Audit and Documentation

6 comments: