MSEndpointMgr
Home » Microsoft Endpoint Manager » ConfigMgr » Console Extension » Clean Software Update Groups console extension for ConfigMgr 2012

Clean Software Update Groups console extension for ConfigMgr 2012

A few months ago I created a script that would assist ConfigMgr admins with cleaning up their Software Update Groups from expired and superseded Software Updates. Although this script needed manual interaction by selecting what Software Update Group to clean, specifying to keep the content or remove it, I think it was a huge help to the community. I was contact by a fellow named Merlijn who had made his own contributions to the script and it gave me some ideas. The first thing he did was to add the functionality to select only to clean Expired Software Updates. With this addition, administrators that are managing supersedence manually have more flexibility to control their environment. So I’ve decided to update the Clean-CMSoftwareUpdateGroup.ps1 script with his code, and made some alterations myself so that it can now be leveraged as a console extension to clean all of the Software Update Groups in four different ways. From the comments I received on the previous script, it occurred to me that the readers of this blog really wanted to automate this workflow in every way. You spoke and I listened, so I hereby bring you the updated version of this script, now as a console extension. Although I highlight the possibility to use this as a console extension, the script is built to be used in any manner that might suit the admin.
With this updated script, you now have the option to clean your Software Update Groups with the following criteria:

  • Expired and Superseded (Remove content)
  • Expired and Superseded (Keep content)
  • Expired Only (Remove content)
  • Expired Only (Keep content)

Download the console extension

You can download the console extension from the TechNet Gallery.

Install the console extension

There are two ways that you can install this console extension, either by running the Invoke-ToolInstallation.ps1 script that comes in the package, or by manually copying the content to it’s designated location and editing the XML file.

Automated installation

1. Download the zip-file from the TechNet Gallery and unpack it to e.g. C:\Temp\CleanSoftwareUpdateGroups. You should now have the following files in C:\Temp\CleanSoftwareUpdateGroups:

  • CleanSoftwareUpdateGroups.xml
  • Invoke-ToolInstallation.ps1
  • Clean-CMSoftwareUpdateGroups.ps1

2. Close the ConfigMgr console, open an elevated PowerShell console and run the following command to install the tool (Path parameter should point to a location where the script file will be stored, and the SiteServer parameter should be the name of the site server, e.g. a Primary Site server):

.\Invoke-ToolInstallation.ps1 -SiteServer CAS01 -Method Install -Path C:\Scripts -Verbose
131_4

3. Re-launch the ConfigMgr console.

Manual installation

1. Download the zip-file from the TechNet Gallery and unpack it to e.g. C:\Temp\CleanSoftwareUpdateGroups. You should now have the following files in C:\Temp\CleanSoftwareUpdateGroups:

  • CleanSoftwareUpdateGroups.xml
  • Invoke-ToolInstallation.ps1
  • Clean-CMSoftwareUpdateGroups.ps1

2. Close the ConfigMgr console and copy Clean-CMSoftwareUpdateGroups.ps1 from C:\Temp\CleanSoftwareUpdateGroups to e.g. C:\Scripts (it’s important that you place it in a non-temporary location, since the CleanSoftwareUpdateGroups.xml file will point to this location for referencing the script).
3. Edit the CleanSoftwareUpdateGroups.xml file on each of the lines (4 of them) that starts with <Parameters>, amend the parts specified in brackets (#), e.g. from:
-executionpolicy bypass -file #PATH# -SiteServer #SERVER# -ShowProgress -Verbose
to the following:
-executionpolicy bypass -file “C:\Scripts\Clean-CMSoftwareUpdateGroups.ps1” -SiteServer CAS01 -ShowProgress -Verbose
4. Go to <ConfigMgr console root directory>\XmlStorage\Extensions\Actions. You can get the path by running a PowerShell console and typing:

$env:SMS_ADMIN_UI_PATH

5. Create a directory in the Actions folder called:

  • 23e7a3fe-b0f0-4b24-813a-dc425239f9a2

6. Copy the CleanSoftwareUpdateGroups.xml file from C:\Temp\CleanSoftwareUpdateGroups to the directory recently created.
7. Re-launch the ConfigMgr console.

Using the Clean Software Update Groups console extension

Once you’ve successfully installed the console extension, you can launch it by right clicking on the Software Update Groups node in the Software Library node:
131_2
Once the script has done it’s magic, the end result of your Software Update Groups view could look like this:
131_3

(13129)

Nickolaj Andersen

Chief Technical Architect and Enterprise Mobility MVP since 2016. Nickolaj has been in the IT industry for the past 10 years specializing in Enterprise Mobility and Security, Windows devices and deployments including automation. Awarded as PowerShell Hero in 2015 by the community for his script and tools contributions. Creator of ConfigMgr Prerequisites Tool, ConfigMgr OSD FrontEnd, ConfigMgr WebService to name a few. Frequent speaker at conferences such as Microsoft Ignite, NIC Conference and IT/Dev Connections including nordic user groups.

106 comments

  • Hello !
    I’m a bit late to the party but I’m curious. How did you build the console extension? Did you used the Console Extension Builder?
    If yes, How did you isolated that XML? I used the Console Extension Builder to add a “Collection Membership tab” to the Device view but I had to copy the complete XmlStorage folder to copy the extension over other CM console.
    I’m starting to learn how to expand SCCM and I have a few ideas so some insights from someone like you could help a lot. Especially on how to get this isolated extension file. 🙂

  • Hello,
    I would like to know which Security roles are required for this process to be available for a group of user. SCCM 1802 almost 1806.
    The Full Admins have access to the right click after installation but apparently theyr are the only ones.
    Thanks,
    Dom

  • Save me a lot of time thanks a lot.
    Does it work also on 1802, 1806?
    Does the redistribution of the SG is manual?
    Thanks,
    Dom

  • Hi.
    Does this script delete the updates from the distribution point and from WSUS folder?

  • Has anyone tested with SCCM CB 1802? Seems like it would not work anymore.
    The black Powershell window opens, , but nothing happens.

  • Hi
    I have CB1706 on server 2016
    when running the script in elevated powershell I get the following error:
    C:\Users\peterpan\Desktop\cleansoftwareupdategroups\Invoke-ToolInstallation.ps1 : Cannot validate argument on
    parameter ‘Path’. Unable to locate part of or the whole specified path, specify a valid path
    At line:1 char:75
    + … on.ps1 -siteserver SCCMpr1 -Method Install -Path C:\Scripts -Verbos …
    + ~~~~~~~~~~
    + CategoryInfo : InvalidData: (:) [Invoke-ToolInstallation.ps1], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Invoke-ToolInstallation.ps1
    Thank you!!

  • Has anyone tested, used the extension in SCCM CB (1610…in my specific case)….Been using it for years in SCCM 2012…wondering if I can bring it into CB?

  • Hi,
    This looks great. However I’m trying to use it to clean up two Primary Servers and it keeps saying “Unable to save changes to . Can you advise what could be causing this?
    It runs through groups where no changes are required, but as soon as it hits the first group requiring a clean I get:
    Performing the Operation “Clean ‘1’ updates on target “SUG name”
    Unable to save changes to “SUG name”
    It then falls over and stops processing anymore. It does this as I said at the first group it comes across that requires the removal of content, so I’m actually getting nothing done. I haven’t seen it successfully do a clean yet.
    Any help greatly appreciated.

  • I keep getting the Error Unable to determine Site Code
    I verified and my site code is correct.
    Error message below from ISE
    Cannot validate argument on parameter ‘SiteServer’. The “Test-Connection -ComputerName $_ -Count 1 -Quiet” validation script
    for the argument with value “AK1” did not return a result of True. Determine why the validation script failed, and then try the command again.
    + CategoryInfo : InvalidData: (:) [Clean-CMSoftwareUpdateGroups.ps1], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Clean-CMSoftwareUpdateGroups.ps1
    I set the computer name to the server of my SCCM and then I got the error of
    WARNING: Unable to determine Site Code
    Please help.
    Thanks!

    • Hi Craig,
      Yes, it works well with ConfigMgr Current Branch (1511, 1602 and 1606) as far as I’ve seen. There should not be any fundamental changes between ConfigMgr 2012 R2 (and SP1) and Current Branch releases that affects this script.
      Regards,
      Nickolaj

  • Figured out the Query to find updates that are not required by any machine, might I humbly request you consider a future revision adding an option to clear these as well.
    SELECT SU.CI_ID FROM SMS_SoftwareUpdate AS SU JOIN SMS_CIRelation AS CIR ON SU.CI_ID = CIR.ToCIID WHERE CIR.RelationType = 1 AND SU.NumMissing = 0

  • Hello Nickolaj, great script and console idea. May I ask a dull question, does the ‘Remove Content’ option delete the stored files in the source folder or is it the distribution packages that is deleted? or both? Trying to find a way to weed out what is not required in the source folder.

  • Hello Nickolaj, awesome script, it works like a charm!
    I would like to ask you for a thing. Is there a way to alter this script the way that this right click would be applicable to a specific SUG, instead of the “Software Update Groups” on the left menu?
    The reason is simple – I would like to clean just a particular/single SUG, not all of them at once.
    Thank you beforehand.

  • Loving the Script use it a lot, thanks for the latest update. Can I make a humble request for another feature. Add the ability to also remove updates that no have a “0” for required. Removing them “0” required from the software update groups is easy in the console that’s just a search criteria and edit membership its rather more tricky to hunt them down among the distribution packages.

  • yes sorry you are correct, i just downloaded the new script and all is working now
    thanks for your help

  • This is my xml script in c:\temp:
    xml version=”1.0″?>


    DefaultHomeTab
    ContextMenu

    AdminUI.CollectionProperty.dll
    Microsoft.ConfigurationManagement.AdminConsole.CollectionProperty.Properties.Resources.resources


    AdminUI.UIResources.dll
    Microsoft.ConfigurationManagement.AdminConsole.UIResources.Properties.Resources.resources
    SUM_Update



    DefaultHomeTab
    ContextMenu

    AdminUI.CollectionProperty.dll
    Microsoft.ConfigurationManagement.AdminConsole.CollectionProperty.Properties.Resources.resources


    AdminUI.UIResources.dll
    Microsoft.ConfigurationManagement.AdminConsole.UIResources.Properties.Resources.resources
    SUM_Update

    “C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe”
    -executionpolicy bypass -file “C:\Scripts\Clean-CMSoftwareUpdateGroups.ps1” -SiteServer servername -Option ExpiredSuperseded -RemoveContent -ShowProgress -Verbose



    DefaultHomeTab
    ContextMenu

    AdminUI.CollectionProperty.dll
    Microsoft.ConfigurationManagement.AdminConsole.CollectionProperty.Properties.Resources.resources


    AdminUI.UIResources.dll
    Microsoft.ConfigurationManagement.AdminConsole.UIResources.Properties.Resources.resources
    SUM_Update

    “C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe”
    -executionpolicy bypass -file “C:\Scripts\Clean-CMSoftwareUpdateGroups.ps1” -SiteServer servername -Option ExpiredSuperseded -ShowProgress -Verbose



    DefaultHomeTab
    ContextMenu

    AdminUI.CollectionProperty.dll
    Microsoft.ConfigurationManagement.AdminConsole.CollectionProperty.Properties.Resources.resources


    AdminUI.UIResources.dll
    Microsoft.ConfigurationManagement.AdminConsole.UIResources.Properties.Resources.resources
    SUM_Update

    “C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe”
    -executionpolicy bypass -file “C:\Scripts\Clean-CMSoftwareUpdateGroups.ps1” -SiteServer servername -Option ExpiredOnly -RemoveContent -ShowProgress -Verbose



    DefaultHomeTab
    ContextMenu

    AdminUI.CollectionProperty.dll
    Microsoft.ConfigurationManagement.AdminConsole.CollectionProperty.Properties.Resources.resources


    AdminUI.UIResources.dll
    Microsoft.ConfigurationManagement.AdminConsole.UIResources.Properties.Resources.resources
    SUM_Update

    “C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe”
    -executionpolicy bypass -file “C:\Scripts\Clean-CMSoftwareUpdateGroups.ps1” -SiteServer servername -Option ExpiredOnly -ShowProgress -Verbose



    DefaultHomeTab
    ContextMenu

    AdminUI.CollectionProperty.dll
    Microsoft.ConfigurationManagement.AdminConsole.CollectionProperty.Properties.Resources.resources


    AdminUI.UIResources.dll
    Microsoft.ConfigurationManagement.AdminConsole.UIResources.Properties.Resources.resources
    SUM_Update

    “C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe”
    -executionpolicy bypass -file “C:\Scripts\Clean-CMSoftwareUpdateGroups.ps1” -SiteServer LUTSRVSCCMPS1 -Option SupersededOnly -RemoveContent -ShowProgress -Verbose



    DefaultHomeTab
    ContextMenu

    AdminUI.CollectionProperty.dll
    Microsoft.ConfigurationManagement.AdminConsole.CollectionProperty.Properties.Resources.resources


    AdminUI.UIResources.dll
    Microsoft.ConfigurationManagement.AdminConsole.UIResources.Properties.Resources.resources
    SUM_Update

    “C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe”
    -executionpolicy bypass -file “C:\Scripts\Clean-CMSoftwareUpdateGroups.ps1” -SiteServer LUTSRVSCCMPS1 -Option SupersededOnly -ShowProgress -Verbose

    • Hi Tom,
      Have you downloaded the amended script from TechNet Gallery? It was recently updated with the fixes to the WQL query.
      Regards,
      Nickolaj

  • hello,
    still cant get this to work for “expired + superseded (remove content)” … i have altered the powershell script (C:\scripts\Clean-CMSoftwareUpdateGroups.ps1) on line 90 to read:
    $Query = “SELECT SU.CI_ID FROM SMS_SoftwareUpdate AS SU JOIN SMS_CIRelation AS CIR ON SU.CI_ID = CIR.ToCIID WHERE CIR.RelationType = 1 AND SU.IsExpired = (1 AND SU.IsSuperseded = 1)”
    }
    any ideas?

  • This console extension no longer works for me in SCCM 1511. Processes all of the SUGs then it just goes away.

  • update**
    after further investigation, it seems to be the expired + superseded (remove content) extension that doesn’t work…
    if I run the superseded (remove content) that gets rid of the expired updates, so there must be something wrong with just one part of it….

    • See previous comments about the Query not being correct: Superseeded updates are also expired.

    • I thought that I’ve updated the file in the Gallery, but it doesn’t seem like it. On row 90, replace with the following:
      $Query = “SELECT SU.CI_ID FROM SMS_SoftwareUpdate AS SU JOIN SMS_CIRelation AS CIR ON SU.CI_ID = CIR.ToCIID WHERE CIR.RelationType = 1 AND (SU.IsExpired = 1 OR SU.IsSuperseded = 1)”
      Regards,
      Nickolaj

  • Hello,
    I wonder if you could help me, I have this working fine on my old sccm console but I cant get it working on a new build of sccm on another domain. I have set it up exactly the same way and the extension is there to run on the software update groups but it doesn’t seem to do anything…
    the windows pops up and then closes very quickly… I cant see any errors just says “no changes detected will not update”
    but there are expired up[dates still in the software update groups.
    My xml file looks ok (has the site server name)
    I set it up using the 1st method you suggested using powershell and it has created the directory and placed the xml file inside.
    any help would be appreciated

  • According to https://msdn.microsoft.com/en-us/library/hh949121.aspx, RelationType 6 = Superseded and RelationType 1 = Bundled.
    Why limit to RelationType 1, when apparently you get all superseded updates when querying for RelationType 6?
    In my environment querying for RelationType 1, i get several updates that are either IsExpired = 0 or IsSuperseded = 0.
    If i Query RelationType = 6, i get only IsSuperseded = 1 and IsExpired either 1 or 0.
    The major difference, is that when using RelationType = 1 gives more results than RelationType = 6 and also a lot more IsDeployed = 1.
    Does it matter if IsDeployed is 1 or 0 when deleting updates?

  • Hi Nikolaj,
    Been a while 🙂
    Got some feedback on your latest version of the script. I’ve found a logic error in the queries that determine whether an updates is either superseded, expired or both.
    As you know, I’m a fan of deleting only expired updates. This is where your new version took me by surprise: it wouldn’t find any expired updates to clean 🙁 Yet there were many to be found. The error was soon found in line 84 of the script. A software update can never have IsExpired set to 1 AND isSuperseded set to 0. If it’s expired, it’s also always superseded. Makes sense when you think about it for a minute. So I changed the query to check for both values being 1.
    $Query = “SELECT SU.CI_ID FROM SMS_SoftwareUpdate AS SU JOIN SMS_CIRelation AS CIR ON SU.CI_ID = CIR.ToCIID WHERE CIR.RelationType = 1 AND SU.IsExpired = 1 AND SU.IsSuperseded = 1”
    Next problem: now the query on line 91 is exactly the same as the one I just edited. Yet, the expected result would be all expired AND superseded updates. Not really. We want to find and clean all updates that are either marked as expired or superseded. So this is an ‘OR’ situation. This results in the following query:
    $Query = “SELECT SU.CI_ID FROM SMS_SoftwareUpdate AS SU JOIN SMS_CIRelation AS CIR ON SU.CI_ID = CIR.ToCIID WHERE CIR.RelationType = 1 AND (SU.IsExpired = 1 OR SU.IsSuperseded = 1)”
    Note the brackets around the ‘OR’ statement. They need to be grouped as otherwise the ‘AND’ operation is processed first.
    One more note, our first query (line 84) can be shortened to evaluate the IsExpired property only. Because if it’s expired, it’s also superseded. You’ll never find one that has IsExpired = 1 AND IsSuperseded = 0
    $Query = “SELECT SU.CI_ID FROM SMS_SoftwareUpdate AS SU JOIN SMS_CIRelation AS CIR ON SU.CI_ID = CIR.ToCIID WHERE CIR.RelationType = 1 AND SU.IsExpired = 1”
    With these changes, I got the script working perfectly for my environment. And super fast! Excellent job on improving the efficiency!
    I’ll email you the edited version of your script.

  • very nice tool thanks a lot!
    I didn’t expect it to re distribute all the content of the software update package to all the DP though 🙂
    I’ll second a delay or manual option to do it later.
    (I used the Expired and Superseded (Remove content))
    thanks

  • Hi There,
    One recommendation I would make is the ability to log the output each time the tool is run. When I run the tool none of the SUGs I have with a yellow icon (denoting they have superseded content) turn green after the tool is finished. Studying the output of the command may help but it disappears to quickly.

  • Hello Nikolaj,
    I am trying to remove all updates from the SUG via sccm 2012 Powershell module. Since there’s no direct cmdlet refereeing to updates deletion within the SUG I noticed that people refer to WMI class SMS_AuthorizationList which they query.
    However, I am struggling a bit with how to query those CI_ID’s or updates when I got the desired SUG already selected like below:
    PS U01:\> Get-WmiObject -Namespace root\sms\site_U01 -Class SMS_AuthorizationList | Where-Object -Property LocalizedDisplayName -EQ ‘TEST patch gremoroup’ | Format-List -Property CI_ID,updates
    CI_ID : 100664251
    updates :
    This SUG consists of three updates and the CI_ID result doesn’t apply to the CI_ID’s that are actually in the queried SUG.
    Updates property is empty…
    Could you please at least point me in the right direction? Am I looking in the correct WMI class as the software update properties are empty in this one I guess. Actually, is it possible to remove the content from the SUG via PowerShell from the specific SUG and those updates aren’t expired or superseded?
    Many thanks in advance
    Regards,
    Zeddy

  • Hello Nikolaj,
    Yor script caught attention to my environment architect 🙂
    This is unbelievably efficient tool. Thank you for this stuff!
    However i have a suggestion or more like a bug report which will be nice to be adjusted in the script. If you have time for this.
    — at step RemoveContet the script checks for content and attempts removal from sources folder. However if there are multiple MS updates and it reported unable to delete for some of them it will not continue with the others and if they are truly downloaded they will be left available in the source location. So will you please make it continue even though the files were not successfully deleted?
    — It will be great if there is a logging option because I was not able to use commands like “Out-file” or “> filename.log”
    Once again thank you for the great work!

    • Hi Pesho,
      Thanks for the bug report! I’ll see if I have the time to update this script, right now there’s a lot going on 🙂
      Regards,
      Nickolaj

  • Hi Steve, I really liked your script, but didn’t want to run it on all of my Software Update Groups at once. So, I took your old script for just one group and made the same type of console extension using that. Would you like it so you can distribute it?
    -Austin

  • Hello Nick,
    The tool looks awesome, but i am not able to use it, I tried installing the Automated as well as the manual option, the tool gets installed,
    but when i try to launch it from the ConfigMgr console nothing happens, a power shell window open for couple of seconds it closes, there is some error red color text on the power shell which i am not able to read.
    Can you please help if i am missing out something here.

    • Joel, did you see my reply to Ben above?
      Did you by chance run the script once without any parameters, before re-running it work the correct Params? If so, that would explain why you are getting the brief powershell window and error.

      • Hey Steve i was able to fix the issue, thank you so much.
        After running the scripts it deleted all the expired updates but when i check my Software Update Groups in the Console it still shows all the expired groups .

  • Hi Nickolaj,
    i like the idea to have it in GUI instead of your old scripted version.
    However, it’s not working for me..
    I used automated installation, in the XML the -SiteServer parameter was just empty, so i corrected it.
    When i run
    c:\scripts\Clean-CMSoftwareUpdateGroups.ps1 with the parameters of the XML everyhting is running fine.
    When i goto to my console and Click the Icon it opens a PS window and closes again, can’t see if anything is displayed in there.
    I installed it on my primary site server.
    Regards
    Ben

    • Ben, and others who see the PS window open and close right away when running the cleanup extension:
      The install script has an issue in parameter validation. If, like me, you first tried running the installer script w/o any parameters, it would have appeared to run without actually installing the extension. Even though it didn’t seem to do anything, the script DID edit the xml file to include the parameters you provided (namely, none.) The next time you run the script, actually including the appropriate parameters, the script would NOT edit the xml file, because the bits of text it looks to replace aren’t in the file anymore. So, the script will now install the console extension but with the xml file missing key details. When you try to run the extension from the SCCM console, it will open a powershell window, flash a red error very quickly, then disappear.
      The solution is to delete the scripts and xml file then re-extract them from the original zip file. This time, don’t run the invoke-toolinstallation.ps1 script without parameters, and it should install a working copy of the console extension.
      Steve

  • Thanks for the utility. However, if I want to know what are the contents of Expired and Superseded(Remove&Keep), How I can do that? ALso what if I want to uninstall the console extension?
    Thanks,
    Shilpy

  • Hello Nickolaj,
    Great Tools it works like a charm.
    Save me few Head ache to deals with cleaning expired updates.
    Thank you very much.
    Best regards
    Thierry

  • Thanks for the utility. However, if I want to know what are the contents of Expired and Superseded(Remove&Keep), How I can do that? ALso what if I want to uninstall the console extension?
    Thanks,
    Shilpy

  • Very nice, thank you Nickolaj for your continuous contributions to the ConfigMGR community.

    • Hi NJ,
      Could you elaborate a bit more on that, please? I’m not sure I understand what you mean with Software Update Compliance Baselines. As of now the tool only cleans up Software Update Groups, in fact all of them even if they’re only used for compliance check or deployed to devices.
      Regards,
      Nickolaj

  • Just wondering if it is possible to edit the xml file and point to required software update group to clean up instead of all at once. I need this because we manage few software update groups and our workstations team manage theirs, i cannot cleanup all groups at once.

  • So after I ran the Expired Only (remove content) it seems like it cleaned up things, but it did not delete the SUPs. Not a big deal to delete them, but they do show up with red X’s.
    Just wondering if this script was supposed to delete the SUPs as well as the content.
    Maybe I missed something?

  • Hi,
    I’m trying to follow this process and I also get the following error when I run the script manually (I did the automated install process but it didn’t seem to update the XML file correctly, but did put the XML file and script in the right place. So I edited the XML file and then retried from the SCCM console but that still failed so I just tried running the command manually)
    .\Clean-CMSoftwareUpdateGroups.ps1 -SiteServer TOPANGA -RemoveContent -ShowProgress -Verbose
    Where TOPANGA is the name of my primary site server
    You must provide a value expression on the right-hand
    At C:\Temp\CleanSoftwareUpdateGroups\Clean-CMSoftware
    + if ($CIID.CI_ID – <<<< noti
    + CategoryInfo : ParserError: (:) [], Pa
    + FullyQualifiedErrorId : ExpectedValueExpression
    My power shell version is 2.0.

    • Hi Nick,
      I just read up on the In and NotIn conditions and it seems they were introduced in version 3.0, this is from the about documentation:
      The In operator was introduced in Windows PowerShell 3.0
      So in your case you’d have to install WMF 3.0 on your Primary Site.
      Regards,
      Nickolaj

      • Nickolaj,
        I thought about doing that but I’ve read several really bad things about installing the WMF 3.0 on a Windows 2008 R2 SCCM 2012 SP1 server. Seems like WMF 3.0 causes lots of problems.
        Maybe this was an early release of WMF 3.0?
        Nick

  • I am seeing this error when I run clean up script
    You must provide a value expression on the right-hand
    At C:\Temp\CleanSoftwareUpdateGroups\Clean-CMSoftware
    + if ($CIID.CI_ID – <<<< noti
    + CategoryInfo : ParserError: (:) [], Pa
    + FullyQualifiedErrorId : ExpectedValueExpression

  • Hi!
    Brilliant tool, now if i only could make it work…
    Did the automated install, have verified that all files are where they should be and that the content of the xml-file is corrrect.
    However nothing is happening when running the tool, besides the PowerShell window popping up and closing just a few Seconds later, no visible text that i can see.
    Have run the console as Admin, still no difference.
    Any ideas?

    • Hi Baard,
      Could you send me an email with the XML file and a screenshot where you the script manually? You can simply open the the XML file and copy the whole script line with the parameters and values and paste it into an elevated PowerShell console (assuming you’ve browsed to the correct folder where the script file exists).
      Regards,
      Nickolaj

      • *facepalm*
        Although reading the documentation several times, i still managed to mistake SiteServer for Site code…
        My excuse is that your example servername resembles out site code…
        Updated the xml with servername and now things are running along as they are meant to 😀
        Thanks 🙂

      • You’re welcome Baard, and I’m glad that you managed to solve the issue. Although, to be fair, my example SiteServer name is five characters and a SiteCode can only be 3 characters 😉
        Regards,
        Nickolaj

  • If we click Remove expired content, is it going to ask specific software update group to get cleaned up or would it clean every thing automatically.
    Thanks

    • Hi HK,
      As it’s described in the blog post, this script will go through all of your Software Update Groups with various outcome due to the selection you make in the right click menu.
      Regards,
      Nickolaj

  • The script does not work for me either. I did the automated install. I have verified the .xml has the right settings.
    When I run it, I get a quick popup with red text and that is it.
    If I try to invoke Clean-CMSoftwareUpdateGroups.ps1″ -SiteServer HSC -ExpiredOnly -RemoveContent -ShowProgress -Verbose from my c:\scripts folder I just end up with
    >> on the screen
    Not sure what I am doing wrong. I have run the console as Administrator still same issue.

    • Hi Kevin,
      Have you installed the console extension on your Primary Site server, or on a remote management system with the ConfigMgr console installed? Either way, in my opinion it should work. Could you try to launch the script manually with the specified parameters in CleanSoftwareUpdateGroups.xml?
      Regards,
      Nickolaj

      • Hi nicklaj,
        I installed it on my Primary Site.
        As stated:
        If I try to invoke Clean-CMSoftwareUpdateGroups.ps1″ -SiteServer HSC -ExpiredOnly -RemoveContent -ShowProgress -Verbose from my c:\scripts folder I just end up with
        >>
        Is there a way to have the screen with the red text stop, so I can see what it is saying. As it only flashes for a quick second, I am only guessing.
        I will try to manually install the extension.
        One thing I did have an issue with the install because of Execution permissions. But I fixed that and it installed without issues with all the settings.

      • Hi Kevin,
        Sorry I missed that part of your comment. Just to be clear, when executing a PowerShell script you need to have the “.\” symbols in front of the script file. Could you email me a screenshot perhaps? You’ll find my contact details in the menu of this blog.
        Regards,
        Nickolaj

      • I am not sure if everyone will have a brain malfunction like me… but I somehow decided that #SERVER# meant site code.
        So everything is fixed after setting it up properly. I was able to run it in the console without issues.
        Just remember that #SERVER# does not mean site code 🙂
        Thanks Nickolaj for pointing out the obvious!!

  • I am seeing this error when I run clean up script “You must provide a value expression on the right-hand side of the ‘-‘ operator. At C:\Scripts\Clean-CMSoftwareUpdateGroup.ps1:75 char:42
    Check the XML and verified right path and site server.
    Thoughts?

  • Doesn’t seem to be working? I can see some red in the Powershell window that flashes up? Any logging? Process to diagnose?

      • I used the automated installation. I was able to invoke the script from the PS command line (in the ISE) and it seems to be working interestingly enough.
        I think I see the problem in the .XML file looks like the script failed to set the siteserver name. I’ll correct that.

      • Hi Bill,
        Great that you found the issue. Did you manage to get it working by correcting the server name?
        Regards,
        Nickolaj

      • I haven’t had an opportunity to retest, my distribution hierarchy is still recovering from the manual run I did that worked. Takes a LONG time to redistribute 40+ distribution packages when they are all triggered for redistribution at the same time, to 92 servers.
        That’s why I had a bit of a panic Monday when I realized what the script would actually do.
        Future enhancement request, throw in a switch so the script cleans up the sources for the deployment packages, but doesn’t trigger redistribution. I know in my situation and probably others are in the same boat we need to redistribute in a more controlled manner.

      • Hi Bill,
        I’ll take a note of your request and see what I can come up with in the near future, shouldn’t be that very hard to add such a switch to the script. I hope that you get your distributions up and running again.
        Regards,
        Nickolaj

  • In this new version, is there still the option to only clean specific software update groups? There are some I’m responsible for and others that I’m not. Thanks!

    • Hi Christian,
      Unfortunately not. You’d have to make use of the old script or extend the console yourself by using that script.
      Regards,
      Nickolaj

  • Thank you for this, I have been using your script for a couple of months but this just makes it even easier. Great work!

    • Hi Alan,
      Does this script clean up all the expired updates from all the software update groups or do we need to specify the name of the update group to be cleaned
      Please advise.

  • Another great tool! Isn’t it true that in ConfigMgr 2012 R2 there is a built-in process that removes the expired updates from the package source and the distribution points, once they have been removed from the SUGs? I guess your tool expedites that process?

  • Thanks for this great extension. I still cannot believe it is not built in…
    Does this work for SCCM 2007?

    • Hi Mathieu,
      Thank you for the kind words. Yeah, it’s a bit surprising to me as well. But I guess that they’ve chosen other priorities. As for if this tool works for 2007, to be frank, I’m not sure. But since the class names should be the same I tihnk it will. I guess you have to give it a shoot in a lab environment.
      Regards,
      Nickolaj

Sponsors

Subscribe

Do you want to be notified of new posts on our site?

Please enter your email address below:

Categories

MSEndpointMgr.com use cookies to ensure that we give you the best experience on our website.