Skip to content

Instantly share code, notes, and snippets.

@kenaniah
Created July 27, 2015 17:26
Show Gist options
  • Save kenaniah/45f2046a7a597484198e to your computer and use it in GitHub Desktop.
Save kenaniah/45f2046a7a597484198e to your computer and use it in GitHub Desktop.
# Connect to Microsoft Online as admin
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "admin@contoso.onmicrosoft.com",(Get-Content admin.pass | ConvertTo-SecureString)
Connect-MsolService -Credential $cred
# Connect to Office365 as admin
$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $cred -Authentication Basic -AllowRedirection
Set-ExecutionPolicy unrestricted
Import-PSSession $session
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment