Canceling a Windows feature configuration

I was running Add-WindowsFeature RSAT-AD-PowerShell on a bunch of 2008 R2 servers today and two of them threw the following error:

“Add-WindowsFeature : A configuration started by Contoso\UserA is currently in progress. Before you can start a configuration, Contoso\UserA must log in to complete the current configuration or the configuration in progress must be cancelled.”

Get-WindowsFeature failed with the same error.

Finding out who UserA was, what they were trying to configure, or getting them to log in and do something was not practical. Restarting the servers did not help.

A quick Google told me that if I went into Server Manager and kicked off the Add Function wizard manually, I would get a check box to cancel the pending configuration. So I manually canceled the pending configurations and completed my install.

I would like to make my scripts able to handle this particular error. Does anyone know a way to use PowerShell in such a situation to find out what is pending and to cancel the pending operation?

I don’t think you see that behavior in Win2012R2 - so Microsoft’s answer to this would be, “upgrade.” We’re not likely to see them retrofit to 2008R2, unfortunately.

Unfortunately, despite our best advice to the contrary, we usually end up writing the script the client wants rather than helping them build the system they need.

Oh, I understand completely - was just trying to point out that you’re probably unlikely to find a good solution in this case. It was a known problem in 2008R2, and fixed later, but the fix wasn’t back-ported. In this case, I think you’d end up having to somehow manually hack the Windows Installer database, although I’m not even sure how you’d go about doing so.