-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #206 from redanthrax/ClearOfficeCache
added script for setting office to clear cache
- Loading branch information
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)." |