MEM-Zone / MEM.Zone

Our ♡ collection of PowerShell scripts and Endpoint Management related stuff 🐵
https://MEM.Zone/GIT
GNU General Public License v3.0
97 stars 10 forks source link

[BUG] Invoke-CCMCacheCleanup - Not detecting or removing most content. #7

Closed PhilAitman closed 1 year ago

PhilAitman commented 4 years ago

Hi loan, I was looking to upgrade from the Technet version of this script (as this version seems so much more polished!) however I'm noticing in testing that most of the content in my test devices cache's is being skipped over. I'm using the following Parameters: Action = All FreeSpace = 100 OlderThan = 0 $RemovePersisted = $true SkipSuperPeer = $false

For Example on one Server I have 10 Cache Entries mostly containing Update CAB's at around 1.5gig each some of which are from January this year, but running the script doesn't seem to detect they're to be removed. Checking the last referenced time in WMI shows they're old. $Cachepath = ([wmi]"ROOT\ccm\SoftMgmtAgent:CacheConfig.ConfigKey='Cache'").Location $cache = get-wmiobject -query "SELECT * FROM CacheInfoEx" -namespace "ROOT\ccm\SoftMgmtAgent" Foreach ($cacheitem in $cache) { $cacheitem.contentID

}

NCU00008 21 January 2020 00:40:45 448ef3f9-86e9-497b-954e-653286ad418f 01 April 2020 01:33:28 NCU00003 28 November 2019 14:14:37 NCU00003 13 February 2020 16:19:56 8a7ad16e-b78e-4b88-91fe-35362d9b69a7 02 June 2020 04:41:12 9b842fe4-2040-40fe-be18-4b88dd88950f 05 February 2020 01:50:05 381e77dc-f15f-4c71-84e1-32d60f26e71a 01 April 2020 01:32:12 a0203bcb-ff0e-42cb-99de-72f265c2426e 08 January 2020 01:25:04 24a6254e-dea0-4acd-ac4f-ae70abd62cdc 19 February 2020 01:22:35 aff2af4a-fb0d-4371-9c90-24a42b3fe359 15 February 2020 04:54:03

PCL-CrisKolkman commented 1 year ago

Hello,

Is there any update on this?

Ioan-Popovici commented 1 year ago

Yes, I'm currently moving and It's hard for me to work on anything right now. But I've started modifying the code.

PCL-CrisKolkman commented 1 year ago

Yes, I'm currently moving and It's hard for me to work on anything right now. But I've started modifying the code.

Awesome, thank you for the update and good luck moving!

PCL-CrisKolkman commented 1 year ago

Yes, I'm currently moving and It's hard for me to work on anything right now. But I've started modifying the code.

Hello @Ioan-Popovici,

Hope you are okay. Is there any update on this?

Ioan-Popovici commented 1 year ago

Hi, yes things are complicated with twins and moving but I've started working on stuff again. I've consolidated my repos and completed some long-due maintenance tasks.

I'll rewrite the whole thing probably this month and then I can look closely at the WMI classes that have this data. Some of them might have become obsolete hence the issues. It's not like this is documented somewhere lol.

But I'll have a working solution and add the option to skip all checks and clean everything.

PCL-CrisKolkman commented 1 year ago

Hi, yes things are complicated with twins and moving but I've started working on stuff again. I've consolidated my repos and completed some long-due maintenance tasks.

I'll rewrite the whole thing probably this month and then I can look closely at the WMI classes that have this data. Some of them might have become obsolete hence the issues. It's not like this is documented somewhere lol.

But I'll have a working solution and add the option to skip all checks and clean everything.

Hello @Ioan-Popovici,

Thank you for the rapid response! Good luck with all that, hope you will sort it all out!

Great, can't wait for your script. At the moment I'm using my own script to remove all folders in ccmcache which are >15 days old, but the script you've written feels much better.

Ioan-Popovici commented 1 year ago

Merged with https://github.com/MEM-Zone/MEM.Zone/issues/13

PCL-CrisKolkman commented 1 year ago

@Ioan-Popovici

Any idea when you have the new script?

Ioan-Popovici commented 1 year ago

Been really busy lately and I don't want to give any timelines anymore because I want to be able to keep my word. What I can tell you is that I'm working on a new blog page and site and this needs to be migrated to it ASAP. There are only about 8 articles that I'll migrate from my old blog and this one is one of them. By migration I mean rewriting to bring up-to-date and bug fixing.

In short, pretty soon would be my best guess...

Ioan-Popovici commented 1 year ago

Work in progress, the whole logic needs to be changed to account for missing WMI data. You’ll have the option to remove data which has incorrect or missing WMI info.

Ioan-Popovici commented 1 year ago

Invoke-CCMCacheCleanup release history

6.0.0 - 2023-07-28