#Requires -Version 5.1 <# JbTecWiz Support Centre -- generated fix script Fault : AutoSave is greyed out, or saving fails with "Upload Failed" Fix : Refresh the sign-in behind the sync Source: https://jbtecwiz.com/support/win-office-autosave-upload Run as : PowerShell as the affected user Expect : 40 minutes Risk : medium Reversible : yes WHEN THIS IS THE RIGHT FIX The path is correct and the work is safe locally, but saving still fails. This fix signs the user out and clears the document cache, both of which discard changes that were never uploaded -- take the local copy from the first fix before you start. HOW TO UNDO IT The cache and the sign-in both rebuild themselves. The local copy from the first fix remains the safety net. This script walks the fix one step at a time and asks before each one. Steps with no command are things you do yourself -- it prints those and waits. Run with -DryRun to print without executing. #> [CmdletBinding()] param( # Print every step and command without running anything. [switch]$DryRun, # Do not ask before each step. Read the script first if you use this. [switch]$Unattended ) $ErrorActionPreference = 'Stop' $script:Failed = 0 function Write-Rule { param([string]$Text) Write-Host '' Write-Host ('-' * 70) -ForegroundColor DarkGray if ($Text) { Write-Host $Text -ForegroundColor Cyan } } function Show-Prose { param([string]$Text, [string]$Colour = "Gray") if (-not $Text) { return } $words = $Text -split "\s+"; $line = " " foreach ($w in $words) { if (($line.Length + $w.Length) -gt 74) { Write-Host $line -ForegroundColor $Colour; $line = " " } $line += "$w " } if ($line.Trim()) { Write-Host $line -ForegroundColor $Colour } } function Invoke-Step { param( [int]$Number, [string]$Do, [string]$Why, [scriptblock]$Command, [switch]$Manual, [string]$Shell = "powershell" ) Write-Rule " Step $Number of 5" Show-Prose $Do "White" if ($Why) { Write-Host ""; Show-Prose $Why "DarkGray" } if ($Manual) { Write-Host '' Write-Host ' -> Do this yourself, then press Enter to carry on.' -ForegroundColor Yellow if (-not $Unattended -and -not $DryRun) { [void](Read-Host) } return } Write-Host '' foreach ($l in ($Command.ToString().Trim() -split "`n")) { Write-Host (" " + $l.Trim()) -ForegroundColor Green } Write-Host '' if ($DryRun) { Write-Host " (dry run -- not executed)" -ForegroundColor DarkGray; return } if (-not $Unattended) { $a = Read-Host " Run this step? [Y]es / [S]kip / [Q]uit" if ($a -match "^[Qq]") { Write-Host " Stopped at your request."; exit 0 } if ($a -match "^[Ss]") { Write-Host " Skipped." -ForegroundColor DarkGray; return } } try { & $Command } catch { $script:Failed++ Write-Host (" Step $Number failed: " + $_.Exception.Message) -ForegroundColor Red Show-Prose "The rest of the fix may depend on this. Read the write-up before carrying on." "Red" if (-not $Unattended) { $c = Read-Host " Carry on anyway? [y/N]" if ($c -notmatch "^[Yy]") { exit 1 } } } } Write-Rule Write-Host ' AutoSave is greyed out, or saving fails with "Upload Failed"' -ForegroundColor White Write-Host ' Refresh the sign-in behind the sync' -ForegroundColor Cyan Write-Host '' Write-Host ' Risk: medium Reversible 40 minutes' Write-Rule if (-not $Unattended -and -not $DryRun) { $go = Read-Host ' Ready? [y/N]' if ($go -notmatch "^[Yy]") { Write-Host " Nothing was changed."; exit 0 } } Invoke-Step -Number 1 -Do 'Confirm the work is saved locally first, as above. This fix signs the user out.' -Why 'Signing out of Office closes documents. Anything unsaved at that point is gone, and this is the step where that happens.' -Manual Invoke-Step -Number 2 -Do 'Check the sync client is running and not paused or in an error state -- the cloud icon in the notification area shows this.' -Manual Invoke-Step -Number 3 -Do 'Sign out of Office from File -> Account -> Sign out, close every Office application, and sign back in.' -Command { Get-Process WINWORD,EXCEL,POWERPNT,OUTLOOK -ErrorAction SilentlyContinue | Stop-Process -Force } Invoke-Step -Number 4 -Do 'If it persists, clear the Office document cache, which holds the local copies Office uploads from.' -Why 'The cache is where an upload sits when it fails. Clearing it discards pending uploads that were never going to succeed -- which is why the local copy taken earlier matters. Office rebuilds the cache on the next open.' -Command { Remove-Item "$env:LOCALAPPDATA\Microsoft\Office\16.0\OfficeFileCache" -Recurse -Force -ErrorAction SilentlyContinue } Invoke-Step -Number 5 -Do 'Reopen the document from the sync folder and confirm it saves.' -Manual Write-Rule " Confirm it worked" Show-Prose 'A test edit saves and appears in the version history in the browser within a minute.' 'White' Write-Rule if ($script:Failed -gt 0) { Write-Host (" Finished with " + $script:Failed + " failed step(s).") -ForegroundColor Yellow Show-Prose 'Read the full write-up at https://jbtecwiz.com/support/win-office-autosave-upload' 'Yellow' } else { Write-Host ' Finished.' -ForegroundColor Green } Write-Host '' Show-Prose 'To undo: The cache and the sign-in both rebuild themselves. The local copy from the first fix remains the safety net.' 'DarkGray' Write-Rule