SCCM SCUP WSUS Delete orphaned update with missing XML

Today I tried to expire old adobe reader and flash updates in SCUP, however some of updates failed to expire, most of them finished with success.
After publish I see only information that Publish Update failed.
What I tried:
1. use regular expire update – normal method
2. I skipped this because my issue was quite differed – https://blogs.technet.microsoft.com/jasonlewis/2010/06/16/how-to-remove-orphaned-scup-updates/

What I found:
1. SCUP trhows that expire update failed – no more errors. On SCUP.log I found:
PublishItem: --- Calling update server API to *expire* update 'Reader 11.0.01 Update (UpdateId:'e066fa50-eab2-4dba-bae2-0a36ca61c2fa' Vendor:'Adobe Systems, Inc.' Product:'Adobe Reader')' Updates Publisher 1601-01-01 00:00:00 11 (0x000B)
PublishItem: Exception occurred attempting to expire the update: The specified item could not be found in the database. Updates Publisher 1601-01-01 00:00:00 11 (0x000B)

This doesn’t give me more info…

2. I inspected WSUS Server log – %ProgramFiles%\Update Services\LogFiles\SoftwareDistribution.log
2016-07-20 07:59:28.569 UTC Warning w3wp.140 SoapExceptionProcessor.SerializeAndThrow Discarding stack trace for user ******\adam.hnat, IP Address ::1, exception Microsoft.UpdateServices.Administration.WsusObjectNotFoundException: The specified item could not be found in the database. ---> System.Data.SqlClient.SqlException: There is no SDP Xml for this Update
at Microsoft.UpdateServices.DatabaseAccess.DBConnection.DrainObsoleteConnections(SqlException e)
at Microsoft.UpdateServices.DatabaseAccess.DBConnection.ExecuteReader()
at Microsoft.UpdateServices.Internal.SingleResultSetSPHandler.ExecuteStoredProcedure(DBConnection connection)
at Microsoft.UpdateServices.Internal.GenericDataAccess.ExecuteSP(String spName, DBParameterCollection args, IExecuteSPHandler handler, Int32 queryTimeoutInSeconds)
at Microsoft.UpdateServices.Internal.GenericDataAccess.ExecuteSP(String spName, DBParameterCollection args, IExecuteSPHandler handler)
at Microsoft.UpdateServices.Internal.DatabaseAccess.CommonDataAccess.ExecuteSPSingleResultSet(String spName, DBParameterCollection args, Type resultType, Int32 queryTimeoutInSeconds)
at Microsoft.UpdateServices.Internal.DatabaseAccess.AdminDataAccess.ExecuteSPGetSdpXmlForUpdate(Guid updateId, Int32 revisionNumber)

It seems that SQL query returned “There is no SDP Xml for this Update”. Let’s check that!
I’ve exected query on SUSDB:
exec exec spGetSdpXmlForUpdate @updateID='E066FA50-EAB2-4DBA-BAE2-0A36CA61C2FA',@revisionNumber=2
and it returned: There is no SDP Xml for this Update

3. In this step I checked what is in spGetSdpXmlForUpdate procedure, check table contents and found that table tbUpdates is populated with Update ID, table tbXML contains UpdateID but doesn’t contain SDP XML for my update

4. [Solution] I was looking for method to fill in missing info based on updated XML avaliable in SCUP … but I was too lazy to write scripts that will fix that. Instead of that I’ve decided to remove update inforamtion from database, so I executed query on SUSDB:
exec dbo.spDeleteUpdateByUpdateID @updateID='dc3d262e-f15f-40b2-8436-ff43fb0cb0dd'
In my case issue was with “Reader 11.0.01 Update” to get updateID see below image:

SCUP update ID
SCUP update ID

5. After success delete in SCUP I pressed “reactivate” button on affected update – it published successfully!
6. I expired affected update, then published again – and success

I hope that if you face same issue this will be useful for you.

SCCM 2012 Update existing collection schedule using Powershell

I found many articles how to set collection schedule for new collection, but unfortunately I didn’t found one that can describe me how to change existing schedule for collection. So I maintain own script. It’s quick and dirty.

#Import SCCM module
Import-Module 'D:\Program Files\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1'

# TT1 - SCCM Site Code
cd TT1:

# usercolls will keep filtered collection that we would like to changeSchedule, in my case there was "AppInst" string in Name
$usercolls = (Get-CMUserCollection | ?{$_.Name -like "*AppInst*" })

foreach ($coll in $usercolls){
# moreinfo about schedule - I randomized minutes and seconds for refresh, beacuse I choosed hourly interval, so there won't be mass query to DB for every hour at exactly same time
$newsched = New-CMSchedule -Start $((Get-Date).AddMinutes($(Get-Random -Minimum 0 -Maximum 59)).AddSeconds($(Get-Random -Minimum 0 -Maximum 59))) -DurationInterval Hours -RecurCount 1 -DurationCount 0 -RecurInterval Hours

$wcol = $coll.psbase.managedobject
$wsched = $newsched.psbase.managedobject

$wcol.RefreshSchedule = $wsched

$wcol.put()
}

I hope that it will be helpful for you!

SCCM 2012 Detect Client Connection Type (Intranet Internet)

Here’s powershell command how to detect if SCCM 2012 Client is Internet or Intranet
$IsInternetClient = (Get-WmiObject -namespace root\ccm -query "select InInternet from ClientInfo").InInternet

$IsInternetclient value is $true when Client is connected over Internet
$IsInternetclient value is $false when Client is connected over Intarnet

SCCM 2012 Installation for lazy part 1 – SQL

In this post I will show you method of installation SCCM for lazy people (like I am). This can be useful for testing purposes as well it might be used in production. Main reason to develop those “scripts” was many dependencies that have to be meet before we install SCCM, like windows features, port configurations, optional product installation. In this article I will be base on Windows 2012 / Windows 2012 R2 with all commands, so let’s start.
Continue reading SCCM 2012 Installation for lazy part 1 – SQL

SCCM 2012 Installation for lazy part 2 – SCCM

Let’s go to Configuration Manager 2012  installation dependencies!

1. Install Windows feature dependencies at one big step

Run powershell, place windows CD/iso in cdrom drive (in my case D: )and type:

Continue reading SCCM 2012 Installation for lazy part 2 – SCCM

How to assign IP address to network interface using powershell

How to assign IP address to network interface using powershell.

First we need to load powershell module responsible for managing Network Adapters:

Import-Module NetAdapter
Continue reading How to assign IP address to network interface using powershell

How to promote new Domain Controler using Power Shell in Windows 2012

Powershell provide us 3 cmdlets to promote new domain conroller in AD:

  • Install-ADDSDomainController – Creates a new domain controller in an existing domain
  • Install-ADDSDomain – Creates a new domain in an existing forest
  • Install-ADDSForest – Creates a new forest

Continue reading How to promote new Domain Controler using Power Shell in Windows 2012