Monday, April 6, 2015

Connecting to Powershell in Office 365

Here's a little script I've got for connecting to a Powershell session in MSOnline or Office365.




Import-Module MSOnline
# Imports the O365 Commandlets

$CloudCredential=Get-Credential -Credential "username"
# Saves your User name and password

$CloudSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://ps.outlook.com/powershell/" -Credential $CloudCredential -Authentication Basic -AllowRedirection -WarningAction SilentlyContinue

Import-PSSession $CloudSession -Prefix 365
# Sets the O365 Commands to start with 365

Connect-MsolService -Credential $CloudCredential
# Connects to O365 services

No comments:

Post a Comment