2016

Automate Backup Of Word AutoRecover Files For More Recovery Options

“I’ve lost a document and can’t find it!” is a common phrase that nobody likes to hear. Most people are working in Microsoft Word for their documents, and although it has a bunch of nice features for autorecovering lost work, it doesn’t cover all scenarios.

There’s even a new feature which autosaves your work as you go; as long as the document is in SharePoint Online or OneDrive for Business.

However, it’s still easy for someone to accidentally close a document and say ‘no’ to saving changes, or other scenarios where documents get overwritten with the wrong information. A document management system (DMS) with versioning (such as SharePoint) can help, but I’ve yet to hear of a company that has 100% of their documents at all times in their DMS!

Anyway, after seeing many scenarios of lost work, I thought there might be another method I can implement to help capture lost data. Microsoft Word’s Autorecover function does work quite well, in keeping an ASD file updated at regular intervals (10 minutes by default) which are saved in C:\Users\username\AppData\Roaming\Microsoft\Word\ (by default). I changed this to 5 minutes rather than 10:

Microsoft Word Options > Save screen

Autorecover will update an ASD file in this folder for each document you have open, on the frequency configured above. That file can get closed or lost depending what the user clicks (again, closing and not saving a document is a scenario that will lose the ASD).

My idea was to back up these ASD files also on a 5 minute interval, giving another avenue to restore lost documents. Because the AutoRecover starts at a random time, a script running every 5 minutes would also start at a random time, and together there’d be a 5 to 10 minute window on copying out the backup files, which isn’t a huge amount of work to lose if someone had been working for hours.

Here’s the PowerShell script I wrote.  It first sets a few variables that can be configured, then does a cleanup of previous backups. If they’re > 2 days old, backup folders are purged or we’d have an ever growing amount of backups. The 2 day value in (Get-Date).AddDays(-2) can be changed.

Then, it runs a filecheck to make sure there’s ASF files to back up. If not, the script breaks. If files exist though, it then creates the Backup folder, creates a sub folder based on the date/time and then copies the ASD files into that folder.

The format of the folders is set at the very start of the script, and again can be changed to a different format if you prefer.

#get-date format https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/get-date?view=powershell-6
 $date = get-date -uformat %Y%m%d%H%M

$SourceDir= "C:\Users\$env:username\AppData\Roaming\Microsoft\Word\"
 $backupdir = "C:\Users\$env:username\AppData\Roaming\Microsoft\Word\Backup\"
 $targetDir = "C:\Users\$env:username\AppData\Roaming\Microsoft\Word\Backup\$date"

Get-ChildItem $backupdir -Recurse | Where CreationTime -lt (Get-Date).AddDays(-2) | Remove-Item -Force -recurse

$Filecheck = get-childitem $sourcedir -filter *.asd

If ($Filecheck -eq $null) {break}

md $targetDir

set-location -path $sourceDir

$files = Get-Childitem -File -filter *.asd

foreach ($file in $files)
 {
 $strippedFileName = $file.BaseName;
 $extension = $file.Extension;
 $sourceFilePath = $file.DirectoryName;
 $DestinationFile = $targetDir + $sourcefilepath.TrimStart($sourceDir) + "\" + $date + $strippedFileName + $extension;
 Copy-Item $file.FullName -Destination $DestinationFile -Recurse -force
 }

(note that the File copy section was taken from here). Save the above as a .PS1 script and you’re good to go.

That worked well after a lot of testing, but the next problem was getting it to run on everyone’s computer. Using a Scheduled Task means we can configure it to run however often we like and whenever we like, as well as being able to push out the task via Group Policy. However, you can’t run PowerShell scripts silently just by running a PS1 file when triggered from Scheduled Tasks.

Scheduled Task pushed out via Group Policy

There is a great workaround here which uses a VBS file to then trigger the above PS1 script. the VBS component itself runs silently which in turn runs the PS1 script silently. Here’s a copy of the script in case the link goes dead, but please read the original link for more details:

Set objShell = CreateObject("Wscript.Shell") 
Set args = Wscript.Arguments 
For Each arg In args 
 Dim PSRun
 PSRun = "powershell.exe -WindowStyle hidden -ExecutionPolicy bypass -NonInteractive -File " & arg
 objShell.Run(PSRun),0
Next

The final catch is then opening an ASD file when you want to recover something. To open a recovered file, in Word go to File > Info > Manage Document > Recover Unsaved Document (if the Info link is greyed out, open a new blank document first). If you had to navigate away from the default location it shows to open the ASD file, you will probably see this error:


Microsoft Word cannot open this file because it is an unsupported file type

As pointed out here, for some reason Word doesn’t like opening the file unless it’s in the special ‘UnsavedFiles’ location. Luckily you can just copy the ASD file into this folder (which by default is C:\Users\%username%\AppData\Local\Microsoft\Office\UnsavedFiles” ) and then open it as per the above method.

Keep in mind, both the PS1 and VBS files also need to be available to the user, which you may want to also push out by Group Policy. Just make sure the file called by the Scheduled Task exists, or the users will see an error saying the file can’t be found, every single time the script runs.

Update 16th July 2018

I’ve adjusted the script slightly for use in a terminal server environment (RDS or Citrix). The scripts are seperate – yes a master one could be created, detect if it’s a client or server, then run the appropriate parts, but I haven’t done that :)

The only real change is getting the list of logged on users from a broker. I could filter these out to only grab the users on the local box but the script runs within a second anyway and shouldn’t find or do anything if the user profile doesn’t have any backup files.

#Terminal Server Version
#get-date format https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/get-date?view=powershell-6
$date = get-date -uformat %Y%m%d%H%M

Import-Module RemoteDesktop
$users = Get-RDUserSession -connectionbroker #brokerservername

foreach ($user in $users){

$login = $user.UserName

$SourceDir= "C:\Users\$login\AppData\Roaming\Microsoft\Word\"
$backupdir = "C:\Users\$login\AppData\Roaming\Microsoft\Word\Backup\"
$targetDir = "C:\Users\$login\AppData\Roaming\Microsoft\Word\Backup\$date"

$SourceDirExcel= "C:\Users\$login\AppData\Roaming\Microsoft\Excel\"
$backupdirExcel = "C:\Users\$login\AppData\Roaming\Microsoft\Excel\Backup\"
$targetDirExcel = "C:\Users\$login\AppData\Roaming\Microsoft\Excel\Backup\$date"


Get-ChildItem $backupdir -Recurse | Where CreationTime -lt (Get-Date).AddDays(-2) | Remove-Item -Force -recurse
Get-ChildItem $backupdirExcel -Recurse | Where CreationTime -lt (Get-Date).AddDays(-2) | Remove-Item -Force -recurse

md $backupdir
md $backupdirExcel


$Filecheck = get-childitem $sourcedir -filter *.asd
$FilecheckExcel = get-childitem $sourcedirExcel -filter *.xar -Hidden

If ($Filecheck -ne $null) {

md $targetDir

set-location -path $sourceDir

$files = Get-Childitem -File "C:\Users" -recurse -filter *.asd

foreach ($file in $files)
{
$strippedFileName = $file.BaseName;
$extension = $file.Extension;
$sourceFilePath = $file.DirectoryName;
$DestinationFile = $targetDir + $sourcefilepath.TrimStart($sourceDir) + "\" + $date + $strippedFileName + $extension;
Copy-Item $file.FullName -Destination $DestinationFile -Recurse -force
}
}

If ($FilecheckExcel -ne $null) {

md $targetDirExcel

set-location -path $sourceDirExcel

$files = Get-Childitem -File -filter *.xar -hidden

foreach ($file in $files)
{
$strippedFileName = $file.BaseName;
$extension = $file.Extension;
$sourceFilePath = $file.DirectoryName;
$DestinationFile = $targetDirExcel + $sourcefilepath.TrimStart($sourceDirExcel) + "\" + $date + $strippedFileName + $extension;
Copy-Item $file.FullName -Destination $DestinationFile -Recurse -force
}
}
}

Excel – Something Went Wrong While Downloading Your Template

Excel 2013 and 2016 have a great inbuilt feature of having online pre-built templates available for different purposes. You find them by going to File > New. Templates such as Family Budgets or Back to School Planners. They’re hosted by Microsoft and download the template as you need them:

List of Excel 2016 Templates

Normally you’d pick the template you want, and use the create option:

Creating an Excel 2016 Template

However, there’s a scenario I found that this doesn’t work, and you’ll see the message ‘Something went wrong while downloading your template’:

Something went wrong

After digging around for a bit, I found this Technet thread which mentioned uninstalling Visio Viewer to fix it. Seems strange, but I tried this and it worked. I wasn’t happy with that as a solution though, so logged a Microsoft case.

I went through the process of capturing fiddler traffic and logs, but was then asked a simple question: Was Visio Viewer 32 or 64 bit? I had a look and it was 64 bit, however the Office 2016 suite itself was 32 bit. I quickly guessed that 32 and 64 bit wasn’t a good mix for Office products, even if they were installed separately.

Sure enough, using Visio Viewer 32 bit with Excel 2016 32 bit fixed the problem.

 

TL;DR – Visio Viewer needs to match your Office/Excel install – 32 bit or 64 bit for both.

Microsoft Word – Show all formatting marks

Microsoft Word 2016 and earlier versions have a handy toggle for ‘Show/Hide paragraph marks and other hidden formatting symbols’. It’s that backwards P looking thing in the Word ribbon:

… but also choosable from Word’s options under the Display section, called ‘Show all formatting marks’:

By default, this option is off. I had a business requirement to have it on by default, which proved harder to work out than I thought.

Normally for Word and Office, a user option is controlled by the registry. Procmon is great for capturing those changes, but I couldn’t see anything when toggling this option.

Jeremy Moskowitz from PolicyPak gave me a hint on finding the solution on this one; Word sets some of it’s user settings at the time of closing Word, rather than changing an option and pressing ‘OK’.

Once I knew that, the setting was easy to find.

HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Word\Options

DWORD Value - ShowAllFormatting

1 - Enabled / On

0 - Disabled / Off

Word will read this setting at startup, and write to it at shutdown based on what the setting was last set to.

Using Group Policy Preferences and setting the option ‘Apply once and do not reapply’ to push out the registry setting will make it the default, but let users change it as they please.

Outlook 2013 & 2016 Blank Screens and Crashing

Update 2nd May 2018:

Microsoft have just released the LAA patch for the issues below, KB4018376 for Outlook 2013, and KB4018372 for Outlook 2016. It seems to work, as I can see a lot more memory available for Outlook 2016 after this patch, and will update later once I can confirm the below issues are resolved.

Original Blogpost:

Since going from Outlook 2010 to 2016, I’ve noticed several issues. They’re outlined on this TechNet article which lists:

  • Buttons on the Outlook ribbon failing to paint properly
  • Email messages displaying either blank or black in the Reading Pane
  • The Navigation Pane failing to draw all folders properly
  • Various rectangles appearing in the Outlook user interface (UI)

There’s also just Outlook crashing/freezing/running slow. This has been an ongoing problem, and I suspected 3rd party addins to be the culprits. That’s sort of true, however it turns out it’s an overall memory issue with 32 bit Outlook having ~2GB of RAM to access, shared amongst all the 32 bit apps running on your computer.

If you want to know that low memory is the cause of your issues, one way is to use the Sysinternals VMMap utility and follow these instructions. If your free memory is under 250MB, then you’re working below the requirements of what Outlook needs to have available to continue running smoothly.

The article above is very well written and detailed, with the primary remediation suggestion being to go 64 bit Office. This isn’t a short term realistic solution for many companies who have legacy 32 bit addons, or vendors who just haven’t got there with 64 bit addins yet. It only takes 1 addin for that idea to come crashing down, and then there’s the testing of all the re-written apps, and then deploying out; an uninstall of the whole Office 2013 or 2016 32 bit suite, uninstalling all the addins, deploying Office 64 bit, deploying the new addins… it’s potentially a huge project to take on.

There is hope though for those of us who can’t go 64 bit (again the article has many suggestions), which is a new feature called Large Address Aware (LAA). It doubles the amount of memory (4GB) available to the Office apps. It’s already rolled out to Outlook 2016 build 1709. That makes sense if you’re using the Click to Run (CTR) version of Office 2016, but the MSI version that many still use hasn’t got this update yet. Referring to the TechNet article again on this issue, there’s no exact specific mention that LAA will come to the Click to Run version of Outlook 2016, so we’ll have to wait and see.

If you’re experiencing a less than great experience with Outlook 2013 or 2016, it’s worth understanding the above and seeing if you’re affected. This may drive you to change to Office 2016 CTR, Office 2016 64 bit, or even both – or leave you to work out how you can improve the experience, with potentially disabling Outlook addins that aren’t necessary.

I am trying to work with Microsoft on this issue too, so feel free to ask any questions or make any comments and I’ll see if I can assist.

Welcome to 2017

Welcome to 2017! I figured this was a great time to reflect over 2016, as well as looking forward to what 2017 holds.

Last year I wrote New Year 2016 Resolutions which is worth a rehash to see how I went:

1. Be more personal in what I do (selectively).
I did this a little, but can probably do it a little more. My last blog post in 2016 was an opinion piece, but I need to do more personal I believe.

2. Get less caught up in particular individuals or situations.
Mostly achieved :) It still happened a few times but I walked away quicker, continue working on this one too.

3. Be more positive
I think I did fairly well on this – I’ll still call someone out on it when I don’t agree, but overall I feel like I didn’t dwell on many negative things.

4. Get more involved in communities
Tick :) I was handed the Adelaide Windows User Group to run, and merged with Adelaide System Center User Community to become Adelaide Windows and System Center Community. I’ve also presented in the user group a few times, as well as another short presentation at itSMF. More presentations needed

5. Helping others
I always want to do this more, but I’ve tried to do this where possible. It’s been happening, which is great!

6. Do more writing
I did more but could have done more again. Will see how 2017 goes, I have a few external posts scheduled, and writing this post is a good start.

You can probably see a theme here – I worked towards what I wanted but felt I could have done more. What will 2017 hold for me then?

I’m off to a pretty good start. I was awarded the Microsoft MVP title in the area of Cloud and Datacenter Management! I can proudly display this logo now:

This category covers all these areas:

 

  • Azure Stack
  • Datacenter Management
  • PowerShell
  • Hyper-V
  • Storage
  • Networking
  • High Availability
  • Installation and Servicing
  • Enterprise Security
  • Group Policy
  • Windows Server for Small & Medium Business
  • Linux on Hyper-V
  • Chef/Puppet in Datacenter
  • Container Management
  • Linux in System Center/Operations Management Suite

This doesn’t mean I’m a pro at all of them either… don’t bother asking me about Chef/Puppet right now for example, as I’ve never had to use them in real life! If you want to know what a MVP is, have a look at Microsoft’s overview.

Who knows what this new title will bring, but it’s incredibly rewarding to be recognised at this level. I’m hoping to be able to visit Microsoft HQ as part of the MVP Global Summit later this year too :)

I’ve had a huge response to announcing my MVP title which has been very touching in itself; just people bothering to respond with a ‘congratulatons’ is a very nice feeling – thank you all who have!

Beyond that, I’m really going to be continuing on the points I set back at the start of 2016. Nothing’s really changed there, so I’ll continue down that path.

Right now, I aim to make the most of being an MVP and continuing to do what I do; there’s always lots more to learn, and plenty of opportunities to pass on those new skills and tips.

An area of focus for me will be Azure and Office 365 which is ever changing, and it’s where all the exciting new things are these days ;)

Looking forward to 2017 both work wise and family wise (and continuing to keep the balance between both) – bring it on!