Powershell login Script for Office 365

Copy the following content to a notepad and save as .PS1

Start-Service WinRM
Set-ExecutionPolicy RemoteSigned
Import-Module MSOnline
$O365Cred = Get-Credential
$O365Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $O365Cred -Authentication Basic -AllowRedirection
Import-PSSession $O365Session
Connect-MsolService –Credential $O365Cred

Open the powershell as administrator and run .PS1, it wll ask for Azure Login credentials.


Leave a Reply

Your email address will not be published. Required fields are marked *