Checking OneDrive is healthy and used

Steve Groom 1 Reputation point
2022-11-23T14:47:56.587+00:00

I am trying to detect when a user is not using OneDrive or if OneDrive has issues.
I have had a number of user support issues where files could not be recovered because the user had ignored alerts from OneDrive or even logged out!
Using an MDM tool, I can remotely execute a command to determine the logged in user and then find recent files in the OneDrive folder - the initial development is using Mac / zsh:

#!/bin/zsh  
loggedInUser=$(stat -f "%Su" /dev/console)  
echo "Checking user: ${loggedInUser}'s OneDrive activity"  
cd /Users/${loggedInUser}  
cd "OneDrive - companyName"  
ls -ldt -- **/*[docx,xlsx,pptx,ai,pdf,psd](D.om[1,10])  

I can test the dates returned to alert if nothing is updated in the past few days.
This will work, assuming the user has OneDrive installed and set up for OneDrive for Business, the user is signed in, and there are no sync errors.

I would then run similar commands to see that ~/Desktop and ~/Documents are not being used.

This script is very basic, but functional and will really help me to detect some issues and educate the users.

Where I need help is to know how to tell if OneDrive is not logged in or has problems. I frequently find users creating file and directory names that are allowed locally but won't sync.
i.e.

cd ~/"OneDrive - companyName"  
touch "this will not : sync.docx"  
touch "this will not sync .docx"  
touch " this will not sync.docx"  

How can I use a script to report on OneDrive health?

263484-image.png

OneDrive Management
OneDrive Management
OneDrive: A Microsoft file hosting and synchronization service.Management: The act or process of organizing, handling, directing or controlling something.
1,118 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Steve Groom 1 Reputation point
    2022-12-06T17:41:19.097+00:00

    Hi @Charles Qi_MSFT - writing scripts is not the problem - the question is what commands are available that can be used in a script to get information about oneDrive.

    regards
    Steve

    0 comments No comments