This script automate execute steps for connecting to Office 365.
By choosing only a number, you can manage your Office 365 connection or disconnect
What do you need to know before you begin?
- Make sure you have already installed Windows Azure AD PowerShell
- You must check and be sure your server or your computer has access to the internet
Let’s have a quick look how to execute the script Connect_to_EXO_v1.0 on Windows PowerShell and what this script do for us.
- Login to your computer with Administrator credentials
- Start Windows Azure AD PowerShell “As Administrator”
3. Next step, copy the script Connect_to_EXO_v1.0 on (C:\) drive
4. Let’s start by running the script from Windows Azure AD PowerShell itself.
In case you get weird error messages when you try to run a script, the reason is only one, security settings built into Windows PowerShell include something called the “execution policy” the execution policy determines how (or if) PowerShell runs scripts. By default, PowerShell’s execution policy is set to Restricted that means that scripts – including those you write yourself – won’t run.
Navigate back to Windows PowerShell and set the Execution policy to unrestricted in order to be able to run the script, in that case, use this command to set your execution policy to RemoteSigned or Unrestricted
Note: The Set-ExecutionPolicy cmdlet enables you to determine which Windows PowerShell scripts (if any) will be allowed to run on your computer.
Windows PowerShell has four different execution policies:
- Restricted – No scripts can be run. Windows PowerShell can be used only in interactive mode.
- AllSigned – Only scripts signed by a trusted publisher can be run.
- RemoteSigned – Downloaded scripts must be signed by a trusted publisher before they can be run.
- Unrestricted – No restrictions; all Windows PowerShell scripts can be run.
5. The most common (default) way to run a script is by calling it:
PS C:\> & “C:\Admin\My first Script.ps1”
If the path does not contain any spaces, then you can omit the quotes and the ‘&’ operator
PS C:\> C:\Admin\Myscript.ps1
If the script is in the current directory, you must indicate this using .\ (or ./ will also work)
PS C:\> .\Myscript.ps1
In our case scenario we run the script in the current directory “C:\” so, we must indicate this using .\ and we click Enter
6. Our script now it starts running, select an option from the menu. In my case scenario, I will select option 1 (Connect to Exchange Online) and click Enter
7. Type your credentials (Username and Password) and let the script do the rest for you…
You can download the script, from here Microsoft TechNet Gallery