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?
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.