Skip to content

Commit

Permalink
Merge pull request #206 from redanthrax/ClearOfficeCache
Browse files Browse the repository at this point in the history
added script for setting office to clear cache
  • Loading branch information
silversword411 authored Jan 18, 2024
2 parents 63fb68d + 0dce5b0 commit f7a51d8
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions scripts_wip/Win_Clear_Office_Cache.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<#
.SYNOPSIS
Sets the registry setting to force office to clear the local cache of files.
.DESCRIPTION
The reason this script exists is to force applications to pull the cloud version
of a file instead of using the local cache version for files in OneDrive.
.NOTES
Version: 1.0
Author: redanthrax
Creation Date: 2024-01-18
#>

$sids = Get-ChildItem -Path Registry::HKEY_USERS | `
Where-Object { $_.Name -match 'S-\d-\d+-(\d+-){1,14}\d+$' } | `
ForEach-Object { $_.Name }
$count = 0
foreach ($sid in $sids) {
if (Test-Path "Registry::$sid\Software\Microsoft\Office\16.0\Common") {
$options = @{
Path = "Registry::$sid\Software\Microsoft\Office\16.0\Common\FileIO"
Name = 'AgeOutPolicy'
Value = '1'
}

Set-ItemProperty @options
$options["Name"] = 'DisableLongTermCaching'
Set-ItemProperty @options
$count += 1
}
}

Write-Output "Execution complete. Set for $count user(s)."

0 comments on commit f7a51d8

Please sign in to comment.