locked
How to import MFA enabled Exchange Online Powershell module in ISE? RRS feed

  • Question

  • Hi,

    Does anyone know how to import the MFA compatible Exchange Online powershell module in ISE?

    I installed this and it works fine when requiring MFA. 

    However i'd prefer to use it within ISE. 

    Thank You.

    Wednesday, October 4, 2017 5:49 PM

Answers

All replies

  • You need to import the ps1 file or the underlying dll, located under the appdata folder of your profile. There are examples on how to do this in this thread: https://techcommunity.microsoft.com/t5/Windows-PowerShell/Can-I-Connect-to-O365-Security-amp-Compliance-center-via/td-p/68898
    • Marked as answer by MikeN401 Wednesday, October 4, 2017 6:10 PM
    Wednesday, October 4, 2017 5:59 PM
  • Thanks.

    This in particular does it:

    Import-Module $((Get-ChildItem -Path $($env:LOCALAPPDATA+"\Apps\2.0\") -Filter Microsoft.Exchange.Management.ExoPowershellModule.dll -Recurse ).FullName|?{$_ -notmatch "_none_"}|select -First 1)
    $EXOSession = New-ExoPSSession
    Import-PSSession $EXOSession

    Wednesday, October 4, 2017 6:10 PM
  • How are you getting this to work?  I run it and it always error, "Cannot find path 'C:\Users\[account]\AppData\Local\Apps\2' because it does not exist."  Note the '2' and not '2.0.'  The '.0'' always gets cut off somehow.  Also, even when I look in this directory, there's nothing there PowerShell related anyway.
    Friday, November 3, 2017 4:19 PM
  • honestly I don't use it in ISE, I just use it as a stand alone shell and copy/paste scripts in.

    I had issues with it working consistently.

    Friday, November 3, 2017 4:21 PM
  • @ Doberman Man

    try the following:

    (Get-ChildItem -Path $env:userprofile -Filter CreateExoPSSession.ps1 -Recurse -ErrorAction SilentlyContinue -Force | Select -Last 1).DirectoryName

    @MikeN401

    I´m using the following (see here):

    $PSExoPowershellModuleRoot = (Get-ChildItem -Path $env:userprofile -Filter CreateExoPSSession.ps1 -Recurse -ErrorAction SilentlyContinue -Force | Select -Last 1).DirectoryName
    $ExoPowershellModule = "Microsoft.Exchange.Management.ExoPowershellModule.dll";
    $ModulePath = [System.IO.Path]::Combine($PSExoPowershellModuleRoot, $ExoPowershellModule);

    Import-Module $ModulePath;

    $Office365PSSession = New-ExoPSSession -UserPrincipalName $office365UserPrincipalName -ConnectionUri "https://outlook.office365.com/powershell-liveid/"

    • Proposed as answer by Bastian_W Monday, June 25, 2018 2:17 PM
    Monday, June 25, 2018 2:17 PM