Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] - Running Invoke-CCMCacheCleanup as SCCM package #20

Open
mbradley73 opened this issue Aug 14, 2024 · 6 comments
Open

[BUG] - Running Invoke-CCMCacheCleanup as SCCM package #20

mbradley73 opened this issue Aug 14, 2024 · 6 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@mbradley73
Copy link

mbradley73 commented Aug 14, 2024

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.

@mbradley73 mbradley73 added the bug Something isn't working label Aug 14, 2024
@mbradley73 mbradley73 changed the title [BUG] [BUG] - Running Invoke-CCMCacheCleanup as SCCM package Aug 14, 2024
@Ioan-Popovici
Copy link
Member

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.

CleanShot 2024-08-14 at 15 52 35@2x

@Ioan-Popovici Ioan-Popovici added invalid This doesn't seem right question Further information is requested and removed bug Something isn't working labels Aug 14, 2024
@mbradley73
Copy link
Author

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

  • Throw "Script initialization failed. $($PSItem.Exception.Message)
    

@Ioan-Popovici
Copy link
Member

Ioan-Popovici commented Aug 19, 2024

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

@mbradley73
Copy link
Author

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.

@Ioan-Popovici
Copy link
Member

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

@Ioan-Popovici Ioan-Popovici added bug Something isn't working good first issue Good for newcomers and removed invalid This doesn't seem right question Further information is requested labels Aug 21, 2024
@Life-of-Roy
Copy link

Looking for to the upcoming changes and implementing them in my environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants