Export Office 365 License Expiry Date Report to CSV using PowerShell

Each Office 365 subscription has a set of services and applications that can be purchased for on either a monthly or an annual basis. When you buy a subscription, you can specify the number of licenses needed based on the people in your organization. When the license expires, you need to renew those license plan, else you will end up losing access/data. So, how will you find Office 365 subscription expiry date? 

 

How to view Office 365 License Expiration Date: 

You can check the license expiry date using any of the following methods. 

  1. Check Office 365 license expiry date from Microsoft 365 Admin Center 
  2. Get Office 365 license expiration date using PowerShell 

In the Admin Center, you need to navigate to Billing–> Products & Services. It will show Office 365 subscription plan, expiry date.  

If you are a hater of ever-changing admin portals, I’d suggest you use PowerShell. Before jumping into that, if you want to know more about Office 365 licensing, please refer to the bottom of this blog for FAQs. 

 

How to Check Office 365 License Expiry Date using PowerShell 

You can use Get-MsolSubscription cmdlet to get license expiry date. But, the cmdlet returns result in an unfriendly manner. For example, the license name is shown as SKU instead of a friendly name, and you need to use more cmdlets to get a result in a nicely formatted way. This is exactly where our PowerShell script comes into play. 

Script Highlights: 

  • Exports Office 365 license expiry date with ‘next lifecycle activity date’. 
  • Exports report to the CSV file. 
  • Result can be filtered based on subscription type like Purchased, Trial and Free subscription 
  • Result can be filtered based on subscription status like Enabled, Expired, Disabled, etc. 
  • Subscription name is shown as user-friendly-name like ‘Office 365 Enterprise E3’ rather than ‘ENTERPRISEPACK’. 
  • The script can be executed with MFA enabled account too. 
  • The script is scheduler friendly. i.e., credentials can be passed as a parameter instead of saving inside the script. 

 

Download Script: LicenseExpiryDateReport

 

Sample Output: 

The exported subscription expiry date report contains the following attributes: Subscription Name, Friendly Subscription Name, Subscribed Date, Subscription Type, Next Life Cycle Activity Date, Friendly Expiry Date, Subscription Status. 

The output looks similar to the screenshot below. 

Office 365 license expiry date powershell

 

How to Execute ‘Office 365 License Expiry Date’ PowerShell Script: 

To view licenses expiry date for all licenses, run the script as follows. 

The result will list all Office 365 subscriptions with their subscribed date and expiry date. Using this report, you can renew the subscription before it expires.  

 

How can I Filter the Output? 

You can use params/switches to get a more granular Office 365 subscription expiration report. I have given some of the use-cases of this script. 

  • List all O365 subscription plans and their details 
  • Export Office 365 Trial subscriptions 
  • Get a list of free subscriptions in your organization 
  • Export all purchased subscriptions 
  • Export Office 365 expired subscription report 
  • Get all active subscriptions 
  • Schedule ‘Office 365 subscription expiry report’ 

 

Export Office 365 Subscription Information Report: 

Most admins have this question – ‘what Office 365 subscription do I have?’. Office 365 subscription information report gives detail about Office 365 plan, expiry date, when Microsoft charges for renewal, license status, etc.  

To get this report, run the script as follows: 

You can also refer to the  Office 365 license report to get a list of licensed users with their assigned licenses. 

 

Export Office 365 Trial Subscriptions Report: 

You can use this report to get a list of free trial subscriptions in your organization. By referring to this report, you can cancel the trial or extend your trial period before it expires. 

To get trial subscriptions in your tenant, execute the script with –Trial switch parameter. 

 

Export Office 365 Free Subscription Report: 

Users in your company can activate free subscriptions. Any individual can gain access to some subscriptions like ‘Microsoft Power Apps’ without admin approval. This option available to all users, and admin can’t disable it. 

To get free subscriptions in your organization, you can execute this script with –Free switch. 

 

Export Office 365 Purchased Subscription using PowerShell: 

By viewing the subscription expiry date/next life cycle activity date, you can change the ‘recurring billing settings’ to yearly or once, or you can turn off the renewal. You can also cancel the purchased subscription if needed. 

To get a list of paid subscriptions, run the script with –Purchased switch. 

 

Get a List of Active O365 Subscriptions: 

While the subscription is active, admins and end-users have regular access to data, services, and Office applications. Once it crosses the active state/expires, access is restricted. 

To get active subscriptions report, you can use –Active switch. 

Using this report, you can check the subscriptions’ expiration status. 

 

Find out Office 365 Expired Subscriptions: 

As an admin, you will receive a series of license expiry notification via email and admin center. When the subscription expires, your access to Office 365 gets restricted. For more detail, you can check what happens when Office 365 license expires. 

To get the expired subscriptions, execute the script with –Expired switch. 

With this report, you can reactivate the disabled Office 365 subscription. 

 

Get more Granular Office 365 License Expiration Report:

To get a more granular report, you can use multiple filters i.e., switch parameters

Above report contains both trial and free subscriptions.

 

Above report lists all expired subscription which was purchased. i.e., it excludes free and trial subscriptions.

 

Schedule Office 365 Subscription Expiry Report: 

As said earlier, this script is scheduler friendly. You can pass the credential as a parameter. So, it won’t prompt for username and password during execution. 

You can use Windows Task Scheduler to schedule PowerShell script. 

Note: Before scheduling, please check the user’s MFA status. You can’t pass credentials for MFA enabled account. If your organization enforces MFA, you can use conditional access policy for specific criteria. 

 

FAQs: 

What Happens When Office 365 License Expires? 

When Office 365 subscription expires, it goes to 3 stages that restrict user and admin access gradually. These periods help customers to reconsider their subscription renewal. 

  • Stage 1 – Warning: When your subscription expires, it enters to ‘Warning’ state where users/admins can have unrestricted access to office 365. It lasts for 30 days 
  • Stage 2 – Suspended/Disabled: Once the warning period is over, it goes to the ‘Suspended’ state. It lasts for 90 days, I.e., till 120 days from the expiry date. In this period, users can’t access to anything; admins can access data but can’t assign licenses to users. The global admin can reactivate the subscription if needed. 
  • Stage 3 – Deleted/Deprovisioned: Once the suspended period is over, it moves to the ‘Deprovisioned’ state. In this stage, admins lose access to data, and Microsoft starts to delete data from its server. You can’t renew or reactivate the subscription once it reaches a deprovisioned state. If you want to use this subscription/service, you need to purchase a new one. 

 

Can I still use Office 365 After Subscription Expires? 

Yes. You can use Office 365 even after subscription expiry. Microsoft gives a grace period of 30 days, where everything works as an ‘Active subscription’. 

The below table describes what you can expect when a paid Office 365 business subscription expires. 

license expiry date powershell

 

When does Microsoft Charge for Subscription Renewal? 

Based on ‘recurring billing’ settings, Microsoft charges for renewal. If you see ‘renews on’ near the subscription, you will be charged for subscription renewal on the specified date. 

subscription expiry date powershell

Through ‘Recurring billing settings’, you can check Office 365 renewal status. If you don’t want to renew the subscription, you can turn off the recurring billing and let your subscription expire on its expiration date. 

 

I hope this blog is helpful to know your organization’s subscription plans, license expiry date, and some FAQs related to subscription expiry.