How to Preserve Office Scripts After a Microsoft 365 User Leaves
Question details
Organizations need a reliable method to retain and manage Office Scripts created by employees who are leaving the company, as scripts tied to individual accounts are lost upon deletion.

- Product
- Microsoft 365
- Device & OS
- not provided
- Scenario
- An employee who developed automated workflows is leaving the organization, and their Office Scripts must be preserved and handed over to the support team.
- Observed behavior
- Because Office Scripts are saved in an individual's OneDrive by default, they become completely inaccessible and are eventually deleted when the departing user's Microsoft 365 account is removed.
Ensure you have Microsoft 365 Administrator privileges to access or restore deleted OneDrive accounts, and verify that you have a target SharePoint document library ready to store the scripts.
Migrate Office Scripts to a Shared SharePoint Site
Transferring Office Scripts from a personal OneDrive to a centralized SharePoint site guarantees that enterprise scripts remain accessible to the support team regardless of individual employee status.
To prevent business disruptions, organizations should establish a shared storage and ownership model for automated workflows. Moving scripts to SharePoint allows for centralized management and proper role-based access control.
If the employee's Microsoft 365 account has already been deleted, log in to the Microsoft 365 Admin Center, navigate to 'Deleted users', and restore the account or generate a OneDrive access link within the 30-day retention period.
Access the departing employee's OneDrive and navigate to 'My files'. Open the 'Documents' folder, and then open the 'Office Scripts' folder where the .osts files are stored.
Select the required script files, click the 'Move to' or 'Copy to' button in the top menu, and select your organization's designated SharePoint site and document library.
Open the target SharePoint library, click the gear icon to access 'Library settings', and assign necessary Read or Contribute permissions to your internal support staff to ensure they can maintain the scripts.

Try WPS Office for Cost-Effective Spreadsheet Management
Managing individual Microsoft 365 licenses and account-bound access issues can be complicated and costly. WPS Office provides a lightweight, free alternative with robust local macro capabilities that aren't dependent on cloud accounts.
- 1. Download and Install: Visit the official WPS website to download and install WPS Office for free on your device.
- 2. Open Your Workbooks: Launch WPS Spreadsheet and open your existing Excel workbooks seamlessly without needing any format conversions.
- 3. Automate with Macros: Navigate to the 'Tools' tab to access the built-in Macro editor, allowing you to recreate and manage automations locally without cloud-dependency risks.

Frequently Asked Questions
How long are Office Scripts kept after a Microsoft 365 account is deleted?
By default, a deleted user's OneDrive data—including their Office Scripts—is retained for 30 days before being permanently permanently erased. Administrators can configure this retention period up to 3650 days in the SharePoint admin center.
Where are Office Scripts stored by default?
When an employee creates an Office Script in Excel on the web or Excel desktop, it is automatically saved as an .osts file in their personal OneDrive for Business, specifically inside the 'Documents > Office Scripts' folder.
Can I share an Office Script directly from my OneDrive to my team?
While you can share a script within a specific Excel workbook so others can run it, the master script file remains in your personal OneDrive. If your account is deleted, the shared script will fail to execute for everyone else.




