Office 365 and Azure PowerShell Connection Script

Connects to all Azure and Office 365 services, including - Exchange Online - Azure AD v1.0 - Azure AD v2.0 - SharePoint Online - Skype for Business Online - Exchange Online Protection - Security and Compliance Center - Azure Resource Manager - Azure Rights Manager

 
 
 
 
 
4.4 Star
(20)
4,793 times
Add to favorites
Office 365
1/20/2018
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • Wouldn't you want to ask for the tenant name?
    3 Posts | Last post June 09, 2017
    • Wouldn't you want to ask for the tenant name on Script startup, have the tenant name in a variable or at least tell your users that they need to replace the SharePoint tenant name as well as the tenant credentials?
      
      Or does the script work out of the box and I did something wrong?
    • Hi Dennis. I have seen scripts that prompt for credentials before and I hate them. Entering your username constantly gets really repetitious if you are connecting constantly all day.
      I ended up editing these script with my username so I only have to enter my password. 
      
      The same issue with the tenant name in the SharePoint section. Do you really want to add that information in EACH time you run your connection script?
      
      That is why I created my script the way I did. Edit the script once and save it. 
      When you run it, you will only ever need to enter your password.
      
      To edit your script follow the notes that are in the header of the script. 
      I have copied them here for reference.
      
      Ensure you update the script with your tenant name and username
      - Your username is in the Exchange Online section for Get-Credential
      - The tenant name is used in the Exchange Online section for Get-Credential
      - The tenant name is used in the SharePoint Online section for SharePoint connection URL
      
      For more detail, view the tutorial below
      How to edit the script and connect to Office 365 via PowerShell - 
      http://www.365admin.com.au/2017/01/how-to-connect-to-office-365-via.html
      
      I hope this helps. 
      Edit the script once, save it, and then you will only need to enter your password. I spent a LOT of time creating the script and it works a treat.
      Cheers,
      Terry
    • @Dennis Gaida -
      The new version of this script now includes variables at the start to simplify the editing for your final script.
      
      The tutorial has also been updated.
      How to edit the script and connect to Office 365 via PowerShell - 
      http://www.365admin.com.au/2017/01/how-to-connect-to-office-365-via.html
  • SharePoint errors.
    1 Posts | Last post June 02, 2017
    • If you get the following error -
      
      Connect-SPOService : Could not connect to SharePoint Online.
      At C:\Scripts\Connect-Office365-faulty.ps1:86 char:1
      + Connect-SPOService -Url "https://$($Tenant)-admin.sharepoint.com" -Cr ...
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [Connect-SPOService], InvalidOperationException
          + FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.Online.SharePoint.PowerShell.ConnectSPOService
      
      This is caused by not updating the 'Tenant' variable correctly. You need to follow the guide - http://www.365admin.com.au/2017/01/how-to-connect-to-office-365-via.html - and ensure the variables are correct