PowerShell for Power365®

PowerShell for Power365 | Binary Tree

Did you know that Binary Tree offers PowerShell support for Power365®?

Merger and acquisition activity is more prevalent than ever, and the adoption of a mature migration and integration platform that can help you streamline migration activities and reduce migration project management duties is of paramount importance to the repeated success of your future technology consolidation projects.

Power365 now supports the new Binary Tree PowerShell module.  TWENTY-ONE (21) BRAND NEW CMDLETS to help you automate and script your project for consistent, repeatable and modular solutions. It’s familiar and easy to use. Get details and status on your users’ mailboxes, files and much more. Start workloads based on your schedule. Organize and manage migration activities based on object properties, like department or language.

There is so much we could discuss but I wanted to keep the topic narrow and simple enough for everyone to get just a glimpse of the extensibility the new cmdlets provide within Power365.


One common challenge I often hear from our clients and partners is the desire to customize the existing user cutover process. For those unfamiliar with Power365 terminology, a cutover is the time when the user is ready to finish the move to the destination or target environment. One of the advantages to using Power365 for coexistence is the cutover process is an orchestrated event whereby the user is modified to maintain mail flow, address book visibility and much more. However, while most updates fit most projects, there are always edge cases where a client would like to perform additional actions against a user.


Before the Binary Tree PowerShell module was available, it was virtually impossible to add cutover options without a product enhancement. Those could take longer than a project timeline allows. Now with PowerShell for Power365 you can easily schedule your scripts locally or use Power365 Directory Sync to manage them for you.

Today we are going to solve a fictional company's need to enhance the user cutover process. The client would like to set 2 additional mailbox properties once Power365 has reported back that the cutover is complete. In this case, we would like to disable MAPI access and we would like to ensure new mail is only forwarded to the target, not stored.


First let’s teach you how to install the new modules. It couldn’t be easier.

Install-Module BinaryTree.Power365 -Force


Next let’s show you how to connect to Power365. It's simple once you are issued your secret key by an authorized client administrator. Once you have your secret key you are going to use that to remotely connect to your client’s project data.

# Connect to Power365  
$apiKey = "Enter Key Here"
Connect-BTSession -ApiKey (ConvertTo-SecureString $apiKey -AsPlainText -Force)

In order to run any Exchange Online commands, you will also need to connect to Exchange Online.

#Connect to Exchange Online
$TargetAdminAccount = " Admin@contoso.onmicrosoft.com"
$Targetpasswd = ConvertTo-SecureString "Password1234" -AsPlainText -Force
$TargetCreds = New-Object System.Management.Automation.PSCredential
($TargetAdminAccount, $Targetpasswd)

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri
https://ps.outlook.com/powershell/ -Credential $TargetCreds -Authentication Basic -AllowRedirection
Import-PSSession $Session
Import-Module msonline
Connect-MsolService -Credential $TargetCreds

The Script

Now that you are connected to Power365 and Office365 you can run your script. In this script we are going to get all our users in Power365 in the complete state. After we have our list of users that have completed the cutover, we will verify the list of users requiring updates based on their deliver and forward mailbox property. If this property is true, then the script will proceed with enabling forwarding only and disabling MAPI protocol access to each user’s mailbox.

# Get Power365 Users in the complete state and if store and forward is enabled then set forwarding only and disable mapi
COUsers = @() 
$COUsers = get-btuser -Filter "MigrationState -eq 'Complete'" | select
foreach ($COUser  in $COUsers){
   $MBX = Get-mailbox -Identity $COUser.primarysmtpaddress
   If ($MBX.DeliverToMailboxAndForward -eq $true)
        # Set Forwarding Only on Mailbox user
        $users_mbx = @() 
        $users_mbx = Set-mailbox -Identity $COUser.primarysmtpaddress -
        # Set CAS Mailbox MAPI feature to OFF for mailbox user
        $users_casmbx = @()
        $users_casmbx = Set-casmailbox -Identity $COUser.primarysmtpaddress -MapiEnabled $false 


Now that we have an easily deployable script that can run remotely and unattended, we need to decide how to best trigger it. Since it is PowerShell, the script file can be scheduled to run using your local task scheduler. You may even enhance the script to log transcript or add more validation to the audit trail.

If you prefer to manage your PowerShell scripts from Power365 you can easily do so by setting up a Directory Sync workflow then adding the PowerShell step to the configuration. Once the PowerShell script is part of the workflow, you may schedule the workflow by intervals or specific times, setup alerts to inform you when it is complete and if it failed. Best of all, the management of your scripts is all in the cloud. You don’t need to login to your local server to check task scheduler, you simply login to Power365 and check the most recent log.  

Next decide how you want to run your script. You may run this script manually during specific events, you can schedule it using a program scheduler or you may choose to utilize Power365 Directory Sync to manage your scripts.

What Else?

This is only a small example of some of the possibilities around PowerShell for Power365. If you are in the business of migrations or your company conducts regular mergers, acquisitions and divestitures and you need a solution to automate and schedule all those repetitive activities - Look no further than Power365.

If you want to read more about PowerShell for Power365, check out the Power365 Help Center

More Questions?

Have questions about how to use Power365 for all your tenant-to-tenant migration and integration needs? 

We at Binary Tree can help you with all the above—and much more. Our experts have migration management and planning down to a fine science. And our solutions and services are flexible enough to handle even the most complex enterprise migrations. Contact us to get started.