Thursday, February 23, 2017

SCCM2012 - Applications stuck in state "Installing"

Problem
Some Packages when started, or when there is Mandatory Deployment, start and get stuck in state - "Installing". Due to this other Deployments also have to wait.

They never complete. Even if SCCM client is repaired/reinstalled, the state remains.
Only solution is - Remove the Deployment for that computer.

Reason
It is caused because when the Deployment is running (usually TS Deployment), the machine rebooted before the SCCM agent can finish updating all the WMI classes, but after the actual advertisement is completed. Root/ccm/clientsdk:ccm_program class isn't updated

Resolution
You can delete the instance of the policy for the deployment with powershell:

foreach($i in gwmi -Namespace root/ccm/policy/machine/actualconfig -Class ccm_softwaredistribution -Filter "ADV_AdvertisementID='<advertID>'"){$i.delete()}

Another script does same thing, and sets smstsmgr dependency to ccmexec/wmi
$ccmProgram = Get-WmiObject -Namespace ROOT\CCM\ClientSDK -Class CCM_Program | Where-Object {$_.EvaluationState eq 14}
If ($ccmProgram -ne $null)
    {
        $ccmExecutionRequestEx = Get-WmiObject -Namespace ROOT\CCM\SoftMgmtAgent Class CCM_ExecutionRequestEx | Where-Object {$_.RunningState -eq "NotifyExecution" -and $_.AdvertID -gt "" -and $_.ContentID -eq $ccmProgram.PackageID}
        If ($ccmExecutionRequestEx -ne $null)
            {
                $ccmExecutionRequestEx | Remove-WmiObject
                Start-Process sc.exe -ArgumentList "config smstsmgr depend= winmgmt/ccmexec" -Wait
                Restart-Service -Name CcmExec -Force
            }
     }
 

SCCM2012 - Applications stuck in "past due-will be retried"

Problem


Many times some Applications get stuck in the state - Past Due - Will be retried. This is seen in the Software Center-Installation Status.


Reason

This usually occurs for Deployment which have date in the past, and the status in CCM class is actually installed, but not updated.


Resolution

Simply changing the Deployment deadline time fixes this. There is also a script, which changes the times for all Deployments of past.


Syntax

.\IncrementCMDeploymentStartTime.ps1 –SiteCode <EnterYourSiteCode>

Code

Param(           
    [parameter(Mandatory=$true)]           
    $SiteCode
    )

Write-Host "SCCM 2012 SP1 Deadline Time Increment Script"
Write-Host "Version 1.0"
Write-Host "Parameters"
Write-Host "  SiteCode: "$SiteCode -ForegroundColor Green

function GetCMSiteConnection
{
  param ($siteCode)

  $CMModulePath = Join-Path -Path (Split-Path -Path "${Env:SMS_ADMIN_UI_PATH}" -ErrorAction Stop) -ChildPath "ConfigurationManager.psd1"
  Import-Module $CMModulePath -ErrorAction Stop
  $CMProvider = Get-PSDrive -PSProvider CMSite -Name $siteCode -ErrorAction Stop
  CD "$($CMProvider.SiteCode):\"
  return $CMProvider
}

#Main

#Connect to SCCM, must have SCCM Admin Console installed for this to work
#If this fails then connect with the console to the site you want to use, then open PowerShell from that console
$CM = GetCMSiteConnection -siteCode $SiteCode
Write-Host "Connected to:" $CM.SiteServer
Write-Host
Write-Host "---Updating Deployments---"

foreach ($Deployment in (Get-CMDeployment))
{
  if (($Deployment.EnforcementDeadline -lt (Get-Date).ToUniversalTime()) -and ($Deployment.EnforcementDeadline -ne $null))
  {
    Set-CMApplicationDeployment -Application (Get-CMApplication -Id $Deployment.CI_ID) -CollectionName $Deployment.CollectionName -DeadlineDate ($Deployment.EnforcementDeadline).AddMinutes(1) -DeadlineTime ($Deployment.EnforcementDeadline).AddMinutes(1)
    Write-Host "  "$Deployment.AssignmentID"CI Deadline Updated" -ForegroundColor Green
  }
  else
  {
    Write-Host "  "$Deployment.AssignmentID"CI Skipped, deadline time occurs in the future or not specified" -ForegroundColor Red
  }
}






Reference-https://blogs.msdn.microsoft.com/rslaten/2013/11/26/past-due-applications-not-installing-in-sccm-2012/

Windows restart / shutdown history

Problem

Many times we need to find find out the reasons for Shutdowns/Unexpected restarts of Servers/Workstations. These event are logged in Evenlog with specific EventIDs.

Solution

By checking the specific EventIds, we can find out the time/source of Shurdown/Restarts.
Open Eventvwr and go to System log.
Filter the System log for these EventIds:
6008(The previous system shutdown was unexpected)
1074(The process X has initiated the restart / shutdown of computer...)
1076(he reason supplied by user X for the last unexpected shutdown of this computer is: ....)
http://serverfault.com/questions/702828/windows-server-restart-shutdown-history