locked
Add-WindowsFeature sometimes fails with error 0x800f0902 - The operation cannot be completed because Windows is currently performing another servicing operation RRS feed

  • Question

  • I have a problem with this feature. In PowerShell, overall it works fine, but sometimes it gives me the following error:

    Add-WindowsFeature : The request to add or remove features on the specified server failed.

    Installationof one or more roles, role services, or features failed.

    The operation cannot be completed because Windows is currently performing another servicing operation.

    Wait a few minutes and try running the command again. Error: 0x800f0902

    At line:1 char:1

    + Add-WindowsFeature NET-Framework-Features,NET-Framework-Core,NET-Framework-45-Fe...

    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        + CategoryInfo          : InvalidOperation: (@{Vhd=;Credent...Name=localhost}:PSObject) [Install-WindowsFeature],

        Exception

        + FullyQualifiedErrorId : DISMAPI_Error__Failed_To_Enable_Updates,Microsoft.Windows.ServerManager.Commands.AddWindowsFeatureCommand

    It seems that either the SCEP Update/Scan or the Automatic Maintenance (in the Action center) causes the Add-WindowsFeature to fail. Is there a way to check if these are active and/or wait until these are done, before I install my Windows feature? This way at least the installation should always succeed.

    Like I said, most of the time, it works fine; (for reference:) I use the following commands:

    Import-Module ServerManager
    Add-WindowsFeature NET-Framework-Features,NET-Framework-Core,NET-Framework-45-Features,NET-Framework-45-Core,NET-Framework-45-ASPNET -Source "path to sources share"

    Also added this question to my own blog:

    http://powershelladministrator.wordpress.com/2014/04/02/add-windowsfeature-error-0x800f0902-the-operation-cannot-be-completed-because-windows-is-currently-performing-another-servicing-operation/

    Wednesday, April 2, 2014 4:07 PM

Answers

  • I solved it. It appears that Windows Automatic Maintenance uses the windows task scheduler for its jobs. Thus I could solve it several ways:

    - I can stop all running instances by using the following code:
    Get-ScheduledTask | Where TaskPath -like "*TaskScheduler*" | Stop-ScheduledTask

    - I can wait until maintenance tasks are finished and then continue with my code:

    $CheckIfMaintenanceIsRunning = $true
    While($CheckIfMaintenanceIsRunning)
    {
    $RunningTasks = Get-ScheduledTask | Where TaskPath -like "*TaskScheduler*" | Where State -eq "Running"
    If($RunningTasks)
    {
    Start-Sleep -Seconds 5
    $CheckIfMaintenanceIsRunning = $True
    }
    Else
    {
    $CheckIfMaintenanceIsRunning = $false
    }
    }

    • Marked as answer by Andy Qi Monday, April 7, 2014 9:30 AM
    Friday, April 4, 2014 1:35 PM

All replies

  • I could localize the problem to be the Automatic Maintenance (in the Action Center). Is there a way to pause or disable this during the running of my Powershell script? Or at least is there a check if it is active or not? So I can check that and wait with installing the Windows Feature until automatic maintenance is finished.
    Thursday, April 3, 2014 7:36 AM
  • I solved it. It appears that Windows Automatic Maintenance uses the windows task scheduler for its jobs. Thus I could solve it several ways:

    - I can stop all running instances by using the following code:
    Get-ScheduledTask | Where TaskPath -like "*TaskScheduler*" | Stop-ScheduledTask

    - I can wait until maintenance tasks are finished and then continue with my code:

    $CheckIfMaintenanceIsRunning = $true
    While($CheckIfMaintenanceIsRunning)
    {
    $RunningTasks = Get-ScheduledTask | Where TaskPath -like "*TaskScheduler*" | Where State -eq "Running"
    If($RunningTasks)
    {
    Start-Sleep -Seconds 5
    $CheckIfMaintenanceIsRunning = $True
    }
    Else
    {
    $CheckIfMaintenanceIsRunning = $false
    }
    }

    • Marked as answer by Andy Qi Monday, April 7, 2014 9:30 AM
    Friday, April 4, 2014 1:35 PM
  • Hi,

    I’m glad to hear that you have resolved the issue and thanks for sharing your solution in the forum. This will help others who face the same scenario resolve the issue quickly. If there is anything else I can do for you, please do not hesitate to let me know. I will be very happy to help.

    Best Regards,

    Andy Qi


    Andy Qi
    TechNet Community Support

    • Proposed as answer by dvinton360 Tuesday, June 3, 2014 2:53 PM
    Monday, April 7, 2014 9:30 AM
  • Hi,

    For those of us not living in powershell, I got past this issue by stopping the "Task Schedule Watch" Service.  Was then able to install the features needed.   When done, restarted the server.

    I'm curious as to why this process interferes with the installation of features?

    Dru

    Tuesday, June 3, 2014 2:56 PM
  • Ooops, meant to say 'restarted the service.'

    Tuesday, June 3, 2014 2:58 PM
  • For what I've found out, the Automatic Maintenance checks things like Windows Update / NAP / etc and can this way install updates or programs when it's running. This is why the other processes get 'paused' (or halted might be a better word), if they try to use Windows Installer. It's a precaution to not break your system in case your installer would install something that windows update is currently updating or installing other software.

    Once maintenance is done, all other processes will continue; or if you stop maintenance, the processes continue immediately.

    Tuesday, June 3, 2014 3:09 PM
  • Thanks for this! I already came across this issue where I'm deploying servers through powershell and sometimes I got this issue. Saved me a lot of troubleshooting...

    Kind Regards, Ronald de Wit

    Monday, September 12, 2016 7:20 PM