Previously, I used to connect PowerShell to Windows Azure Active Directory and Exchange Online using the following BAT file:
@echo off
Powershell -noexit -Command "& {
$Credentials = Get-Credential;
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -Authentication Basic -ConnectionUri https://ps.outlook.com/powershell -AllowRedirection:$true -Credential $Credentials;
Import-PSSession $Session;
Import-Module MSOnline;
Connect-MsolService -Credential $Credentials;
}"
I was looking to do the same thing, and I came across this link . Simply running these two commands within a normal PowerShell window allowed me to connect to Exchange Online (with MFA-enabled):
$CreateEXOPSSession = (Get-ChildItem -Path $env:userprofile -Filter CreateExoPSSession.ps1 -Recurse -ErrorAction SilentlyContinue -Force | Select -Last 1).DirectoryName
. "$CreateEXOPSSession\CreateExoPSSession.ps1"
I could then connect using
Connect-EXOPSSession
Instead of importing Exchange Online PowerShell module, you can use Exchange Online PowerShell V2 module.
Currently, I am using EXO V2 module. You can directly install the module from PowerShell gallery.
Install-Module ExchangeOnlineManagement
You can connect to Exchange Online PowerShell using below cmdlet.
Connect-ExchangeOnline
For more info: Connect to Exchange Online PowerShell using EXO V2 module
I solved this by the following;
From your step 7: I did not copy the files at all. I left them where they were. There is no reason why they would not work after copy but I rebuild this machine quite often so wanted to reduce steps.
My Step 8: In the ISE (in my case the directory name is as follows)
cd C:\\Users\\%username%\\AppData\\Local\\Apps\\2.0\\V7MK47Q8.0NZ\\KLJLETPC.4RJ\\micr..tion_d8f8f667ee342b5c_0010.0000_6b4a13fd451b1c00 Import-Module .\\CreateExoPSSession.ps1 Connect-EXOPSSession -UserPrincipalName name@domain.com
Now, there is no reason why this should work as it is not a proper module but it does and has been for a while now.
I can not post a picture as I have no rep but suffice to say when you use "connect-", the first two in the list are AzureAD and EXOPSSession.
And now it is even easier, see: https:\/\/365tips.be\/en\/install-the-new-exchange-online-powershell-v2-module\/<\/a>
Get-Module ExchangeOnlineManagement
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.