Jun 08 2023 07:53 AM
Hi all
I have a script which clears files in the cache folder which works if I run on the laptop manually however I cant seem to get it done via intune?
Here is the script:
# Define the path to the cache directory
$cachePath = "C:\Users\$env:USERNAME\AppData\Local\Microsoft\OneNote\16.0\cache"
# Get all files and folders in the cache directory
$items = Get-ChildItem -Path $cachePath -Force -Recurse
# Iterate through each item
foreach ($item in $items) {
# Check if it's a file or a directory
if ($item.PSIsContainer) {
# Remove the directory and all its contents
Remove-Item -Path $item.FullName -Force -Recurse
} else {
# Remove the file
Remove-Item -Path $item.FullName -Force
}
}
Jun 09 2023 12:37 PM
@AB21805 How are you deploying it? As a script within devices? (Devices - Microsoft Intune admin center) ? And did you select "Run this script using the logged on credentials" ?
Jun 12 2023 02:29 AM
Jun 12 2023 02:46 AM
@AB21805 You can run it as remediation script every day for the logged in user, but do you have a detection script to trigger it?
Jun 12 2023 03:15 AM
Jun 12 2023 10:56 AM
Jun 12 2023 12:23 PM