Hi,
Thanks for posting in Microsoft MECM Q&A forum.
The script is OK. Please try to put your script into a standard package and then create a program for your script using a command-line like:
powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File .\Increase-CCMCacheSize
Here is a great article for your reference: Temporarily Increasing the ConfigMgr Client Cache Size for a Large Application
Thanks for your time.
Best regards,
Simon
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.