Open mbradley73 opened 1 month ago
Hi, You should not try to run it as a package because you are not installing anything. Please run it as a configuration baseline as specified. The error you specified is a generic error and you would need to check the execution logs to see what exactly went wrong.
If you run it as a detection script, you don't need a remediation script. You also need to suppress all output for this to work.
I often use package to run PowerShell scripts that don't need to install anything, so I was trying to do that same thing here. Being that the script requires more than just the file name, and needs various parameters, how do you do that in a baseline? I can only select a script to run in a CI, but don't see a way to set the parameters (like for orphaned content).
Further troubleshooting this, running it manually on my machine, with this command line: .\Invoke-CCMCacheCleanup.ps1 -CacheType "Orphaned" -CleanupType "Tombstoned" , I get this error: Script initialization failed. Cannot validate argument on parameter 'ScriptSection'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again. At C:\clean\Invoke-CCMCacheCleanup.ps1:1766 char:5
Yeah, I get it, but if there's no payload, why use packages?
In a CI you just have to change the default parameters. I'll make a blog post in the future.
Try the new version here
I don't know if it fixes it entirely, but it will fix the error you get so we can see what else is wrong.
The Tombstoned
parameter should not be used with Orphaned
because it doesn't make sense.
The orphaned cache is not supposed to be there because it has no links with the caching system.
I overlooked this when creating the script.
Please try to run the script manually with Tombstoned
and All
and report the result.
Thanks Ioan
Sorry, I was going off the script comments that in the example appeared to include both of those conditions in the command. I've now tried this: Invoke-CCMCacheCleanup.ps1 -CleanupType "Tombstoned" , and it resulted in no errors, but didn't remove anything either. Are orphaned and tombstoned the same thing? Running just Invoke-CCMCacheCleanup.ps1 (which defaults to the All condition I think, right?), worked, deleting almost everything.
Thank you for you assistance on this, it is much appreciated.
So there is a parameter issue.
Tombstoned means items that have passed the cache expiration date an can safely be deleted
Orphaned means wmi items that have no links on disk or disk items that have no links in wmi
I'll add a parameter check and explain these things better on the blog page.
Thanks Ioan
Describe the bug Trying to run the Invoke-CCMCacheCleanup script as a package in SCCM and getting a failure (message ID error 10006).
To Reproduce This is the command I'm using: %SystemRoot%\SysNative\WindowsPowerShell\v1.0\PowerShell.exe -ExecutionPolicy Bypass -NoProfile -WindowStyle Hidden -File Invoke-CCMCacheCleanup.ps1 -CacheType "Orphaned" -CleanupType "Tombstoned"
Expected behavior For the script to clean complete with no errors and ccmcache be rid of orphaned packages.