Home » Office 365 » Gain Guidance to Use PowerShell for Office 365 and SharePoint Online

Gain Guidance to Use PowerShell for Office 365 and SharePoint Online

  author
Chirag Arora   
Published: Aug 18, 2018 • Office 365 • 5 Min Read

Being an administrator of Microsoft Office 365 or SharePoint in a firm, you have permission to use SharePoint Online Management Shell for managing sites, site collections, and users. It is a module of Microsoft Windows PowerShell, which enables users to execute all command line operations. This enhances batch operations in a more efficient manner and, offers only the way for performing few management tasks in OneDrive and SharePoint. Now, how to use PowerShell for Office 365 or in what manner should we connect different O365 to it? All these guidelines are provided in this post to run PowerShell script for Office 365.

Download and Install PowerShell for SharePoint Online on Windows OS

Try https://www.microsoft.com/en-us/download/details.aspx?id=35588 – this link. From here, the setup file of Windows PowerShell application starts downloading.

Note – Even if you are having an old version of Microsoft SharePoint Online Management Shell then also, you need to first uninstall it and then, reinstall it again.

When the setup file completely gets downloaded, install it on your PC having Microsoft Windows OS within it. Finally, you will be done with the initial step to use PowerShell for Office 365 on your local machine.

Prerequisites Before Establishing Connections

  • Execute PowerShell App as an Admin – An individual should be ‘used to’ of this prerequisites because this will be applied whenever he/she opens the PowerShell program. For this, you need to right-click on the icon of PowerShell and choose Run As Administrator from a list of options.
  • Ability to Execute RemoteSigned Scripts – Based upon the PowerShell and Windows version, security of PowerShell varies. Execute Get-ExecutionPolicy command in the Shell wizard and if you encounter ‘Restricted’ then, modify it; else no changes are required. In case of any changes or modifications, use Set-ExecutionPolicy RemoteSigned cmdlet. The ‘RemoteSigned’ is one of the most restrictive settings, which will enable an individual to run the PowerShell script for Office 365.
  • Person Should be O365 Tenant Admin – It is mandatory for an organization to hire an administrator for Office 365 tenants. This individual will be having hold of all employees account. Only this administrator will be having permission to make changes for global users of a firm.
  • PowerShell 3.0 or Above Should be Present – The recent editions of PowerShell already have import modules. If you are eager to know the version of Microsoft PowerShell for SharePoint Online then, execute $PSVersionTable.PSVersion command.

Use Powershell for Office 365 And Entire O365 Apps

Now it is the time to connect the installed PowerShell with different online applications.

  • Save All Credentials on One Side – Office 365 tenant credentials are lengthy and complex. Therefore, ease down the entire procedure by maintaining an Excel sheet that comprises all the usernames and passwords. The administrator account can gain all by executing $MyAccount = Get-Credential. This opens a pop-up box where you can type your credentials and store them into a variable, which you have recently created. Note down one thing that you are not validating the accounts at this stage.
  • Connect PowerShell To Office 365 – This steps simply requires execution of Connect-MsolService -Credential $MyAccount. It will permit you to utilize particular commands so as to manage licenses and users. You can confirm whether the login is successful or not, by running Get-MsolUser. If the entire list of O365 tenants occurs, it means that you are done with connecting PowerShell to Office 365.
  • Connect PowerShell To SharePoint Online – Just one line execution i.e., Connect-SPOService -URL https://MyTennatUrl-admin.sharepoint.com -Credential $MyAccount. Only you have to update the URL value with your own. Suppose https://contoso.sharepoint.com is your SharePoint Online URL, use https://contoso-admin.sharepoint.com as the value in command. You can confirm whether a connection of PowerShell to SharePoint Online is successful or not, by executing Get-SPOSite. This will enlist entire site collections on your PowerShell window.
    Interesting Fact – If you want to view all the commands that are available with your SharePoint Online subscription plan then, just type Get-Command -module Microsoft.Online.Sharepoint.PowerShell and execute it.
  • Connect PowerShell to Skype for Business – All things like Lync, Skype, and Communication server are same. Depending upon the name, there will be rotations in cmdlets and documentation so do not get confused. Establish a remote connection with the online server to a built connection of PowerShell with Skype. First, you need to execute $Skype = New-CsOnlineSession -Credential $MyAccount and when its execution gets completed, run the Import-PSSession $Skype command. On the appearance of WinRM, respond Y for allotting the app required permissions. All of the Skype users can be listed in PowerShell by using Get-CsOnlineUser. You can use this command after successful connection of PowerShell to Skype for Business.

Conclusion

All piece of information that administrators might demand at the beginning stage to use PowerShell for Office 365, is mentioned in this post. You can make use of basic commands and after that, enjoy using the MS PowerShell for SharePoint Online or Office 365.

By Chirag Arora

Chirag Arora is a digital marketing consultant and a meticulous content proofreader. With a focus on enhancing online presence and content quality, Chirag brings a unique blend of digital expertise and editorial precision. His dual role ensures that your digital content not only reaches its intended audience but also does so with clarity and accuracy, making him a trusted partner in elevating your online presence.