Also before you can use this script you need to be connected to Office 365 – especially to Connect-MsolService and Exchange Online. If you're using my module, you could use something like the code below to connect. It's a simple True/False based on the selection of services and making sure your data is correct. Of course, it requires you to have all pre-requisites installed. So you need all those Office 365 modules that Microsoft provides, or you will get errors. I'm slowly working on an optimized version of this Connectivity Pack where I'll bundle this up to one command, probably with the installation of required modules from Microsoft but haven't had time to dive into it since it works for me entirely.