If the answer is “Yes,” you came to the right place!
The Power of PowerShell – Article Series
Q: Why should I use the “boring” command line interface instead of using the friendly web interface?
A: PowerShell is a very powerful tool. By using PowerShell, we can execute bulk operations. The meaning of the term “bulk” is: using a single command for creating configuration settings for a large group of objects such as users and mailboxes.
Additionally, although we can perform many functions using the Web interface, a significant part of the management tasks can be performed only by using PowerShell.
Office 365 and PowerShell Basic Terms
Office 365
Office 365 is a suite of cloud application/services that includes: Exchange Online, LYNC Online, SharePoint Online + Administration environment for managing: users, groups, licensing, domains etc.
Office 365 management
Along the article, we will mention the term “Office 365 management” or “connecting to Office 365”. The meaning is: connecting to the Office 365 parts that serve as an “envelope” of all other Office 365 Services/Applications (such as Exchange Online, SharePoint Online, and LYNC Online).
This part includes components such as user and group object (Azure Active Directory), Domain name’s management, mail migration, SSO (Single sign on), subscription and license management and more.
Exchange Online management
Exchange Online is the Microsoft cloud version of Exchange server 2013 (This information was correct at the time when the article was written).
The management of Exchange Online is implemented by using the Web interface (ECP – Exchange control panel) and, of course, by using PowerShell. Exchange Online management includes tasks such as mailbox management (Mailbox permissions, sharing calendars, etc.), Transport Role, Retention Policy, archive mailbox and more.
PowerShell console
The PowerShell console is a built-in component in all the modern Microsoft OS such as windows 7/8 and Windows server 2008/2012. In case that you use “older” OS such as Windows XP, you will need to download and install the PowerShell and additional components.
cmdlets
PowerShell commands are called: cmdlets. The cmdlets are small or “mini application” that serves for management of specific objects such as:
users, group, file, service, etc.
The OS PowerShell includes a predefined set of cmdlets for OS management, but if we want to use PowerShell cmdlets for a specific “application”, we need to download a dedicated set of cmdlets that was created for the specific software or service (such as Office 365 or Exchange Online).
Remote PowerShell
Most of the time, we use the PowerShell for managing local or domain member’s machines. But what about the option of managing remote infrastructures such as the cloud?
The ability to use local PowerShell console for managing remote infrastructure such as Office 365 and Exchange Online, described as: Remote PowerShell or PowerShell Remoting.
This article is all about how the use remote PowerShell for connecting to Office 365.
Remote PowerShell: Office 365 versus Exchange Online
It’s important to understand that we use remote PowerShell for managing two environments. We need to use different sets of PowerShell
cmdlets for each of the infrastructures, and the way that we implement the remote PowerShell session for each of the environments is different.
For example – when we use remote PowerShell session for managing the Exchange Online environment, all of the required cmdlets will be downloaded in “real time to the local host, as part of the remote PowerShell session. The process of creating a remote session to Office 365 requires downloading and installing specific cmdlets before we can create the remote session.
We really want to know what you think about the article
Question: I have a script that sets up the remote PowerShell connection to Exchange Online first, and then imports the session. Then it connects to the Office 365 Online Service. Is this the right order to set up the connections, or should it be the other way around?
# Connect to Exchange Online
$LiveCred = Get-Credential
$ExchOlSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection
Import-PSSession $ExchOlSession -AllowClobber
# Connect to Office 365 Online Service
Connect-MSOLService
# Create the License Option
$Office365SKU = “TenantName:ENTERPRISEPACK_GOV”
# Set new user’s location
$UsageLocation = “US”
Set-MsolUser -UserPrincipalName $NewUser -UsageLocation $Usagelocation
# License the new account. This action also creates the mailbox in Exchange Online
Set-MsolUserLicense -UserPrincipalName $NewUser -AddLicenses $Office365SKU
# Set Litigation Hold on the new mailbox
Set-Mailbox $NewUser -LitigationHoldEnabled $True
Remove-PSSession $ExchOlSession