Connecting to Office 365 with PowerShell

This is just s simple script for connecting to Office 365 with PowerShell.


# Import Required PowerShell Modules
# Note - the Script Requires PowerShell 3.0!

Import-Module MSOnline 

# Office 365 Admin Credentials
$CloudUsername = 'username'
$CloudPassword = ConvertTo-SecureString 'password' -AsPlainText -Force
$CloudCred = New-Object System.Management.Automation.PSCredential $CloudUsername, $CloudPassword 

# Connect to Office 365
Connect-MsolService -Credential $CloudCred

Advertisement