Remove-ContentFromCache error

Hi, I am using the latest PSADT version 3.10.1 and having an issue figuring out how to remove the cache that was created with Copy-ContentToCache.
I put the Remove-ContentFromCache in the Post Uninstall section, even as the last or first line, and I always get a "Failed to removed cache folder. I have even directed the function to the exact path with the -Path switch, and no luck…same error. I am just using the remove folder function right now, but curious if anyone has had success with this feature. The MSI I am testing is a simple test MSI and has no remnants in memory when installed or uninstalled. Thanks. Jeff

In PSADT version 3.10.1, you can use the Remove-ContentFromCache function to remove cached content created with Copy-ContentToCache. But ensure correct syntax and path usage. If you encounter issues, consider troubleshooting with the PSADT community or checking for any known bugs or updates related to this feature.


Thanks Anna,
I figured out a fix.
I used the two functions with default paths and even tried giving an absolute path for the remove function and it failed. I figured out the issue. I had the remove function in the post uninstall. I placed Remove-ContentFromCache, just above Exit-Script -ExitCode $mainexitcode

## Call the Exit-Script function to perform final cleanup operations
    If ($deploymentType -ieq 'Uninstall')
		 Remove-ContentFromCache -ErrorAction SilentlyContinue
#End Remove-ContentfromCache 
	Exit-Script -ExitCode $mainExitCode

I think the Remove-ContentFromCache did remove folders and a files, but always left the main script, Deploy-Application.ps1 and gave an error about not being able to remove that ps1. After moving the Remove-ContentFromCache above the Exit-Script line, it removed all files and folder, plus the ps1 file. I guess logic from my thinking thought Post-Install was a great place to put the Remove-ContentFromCache, and it obviously got held up trying to delete the ps1 that was in play. By the way, I like the idea of leaving the default locations so far, as I don’t have to use the -path parameter…smile. Thanks for responding.

1 Like