none
need help - Exchange Online powershell MFA command execution is it charged? need answers few queries to clarify RRS feed

  • Question

  • I have performed as below to have exchange online commandlets execution with MFA ( as basic authentication is getting retired by end of Oct 2020) have few queries below please help

     https://outlook.office365.com/ecp/  go to hybrid

    Install the exchange online powershell version this installs all required modules and dlls 

    1. Import-Module  Microsoft.IdentityModel.Clients.ActiveDirectory.dll, Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll,Microsoft.Exchange.Management.ExoPowershellModule.dll

    2. $ps1 = New-ExoPSSession -UserPrincipalName xxxx@xxx.onmicrosoft.com -ConnectionUri https://outlook.office365.com/powershell-liveid/ -AzureADAuthorizationEndpointUri https://login.windows.net/common -Credential $cred
    3. Import-PSSession $ps1
    4. Get-Mailbox

    please let me know

    1. is it charged to my tenant account ? for every  commandlet execution or for runspace 

    2.do I need to use the exchange online powerhsell V2 module will it be same or any differences with  the two approaches 

    https://docs.microsoft.com/en-us/powershell/exchange/exchange-online/exchange-online-powershell-v2/exchange-online-powershell-v2?view=exchange-ps

    3. how do I check if the command let executed is with MFA enabled ? 

    4. How to do I check if the command let executed is charged X amount ?


    Arathi


    • Edited by Arathij Monday, December 9, 2019 7:17 AM
    Monday, December 9, 2019 7:16 AM

Answers

  • Hi Arathij,

    I am writing here to confirm with you how thing going now?

    If the above suggestion helps, please be free to mark it as an answer for helping more people.

    Regards,

    Kyle Xu


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    • Marked as answer by Arathij Monday, December 16, 2019 8:42 AM
    Monday, December 16, 2019 8:38 AM
    Moderator

All replies

  • Hi Arathi,

    1. You won't be charged for executing Exchange Online cmdlets
    2. The code you mentioned connects to Exchange Online PowerShell with basic authentication. Whereas, EXO v2 module connects Exchange Online PowerShell with Modern auth
    3. During session creation, if you asked for additional authentication like verification code, App password, you have created a session with MFA enabled account.

    Monday, December 9, 2019 9:33 AM

    Hi Kathy, 

    1. We are importing the module Microsoft.Exchange.Management.ExoPowershellModule.dll and executing the new-ExoPSSession command which uses graph calls and avoids basic authticatication  am I right?

    2. as here(link below) connect-ExoPssession commandlet is from "CreateExoPSSession.ps1" this script is installed upon installing the exchange online powerhsell module from here https://outlook.office365.com/ecp/

    if we look at the CreateExoPSSession.ps1 script it does the same New-ExoPSsession (without basic authtication) and import this session and execute the command 

    can you please share any sample for EXO v2 Module , does this causes authentication code generated upon executing the command let ?

    https://gallery.technet.microsoft.com/Connect-to-Exchange-Online-7d7365e0?ranMID=24542&ranEAID=je6NUbpObpQ&ranSiteID=je6NUbpObpQ-bdukHHRmIGvAqQCPenUehw&epi=je6NUbpObpQ-bdukHHRmIGvAqQCPenUehw&irgwc=1&OCID=AID2000142_aff_7593_1243925&tduid=(ir__tgoefbiorwkfrjuzkk0sohzz0n2xgdxpyvbwvn2e00)(7593)(1243925)(je6NUbpObpQ-bdukHHRmIGvAqQCPenUehw)()&irclickid=_tgoefbiorwkfrjuzkk0sohzz0n2xgdxpyvbwvn2e00


    I think these are the two ways to achieve exchange online command lets execution without Basic Authentication - please confirm on this 

    https://docs.microsoft.com/en-us/powershell/exchange/exchange-online/exchange-online-powershell-v2/exchange-online-powershell-v2?view=exchange-ps

    https://docs.microsoft.com/en-us/powershell/exchange/exchange-online/connect-to-exchange-online-powershell/mfa-connect-to-exchange-online-powershell?view=exchange-ps


    Arathi




    • Edited by Arathij Monday, December 9, 2019 10:49 AM
    Monday, December 9, 2019 10:45 AM

    Hi Kathy, 

    1. We are importing the module Microsoft.Exchange.Management.ExoPowershellModule.dll and executing the new-ExoPSSession command which uses graph calls and avoids basic authticatication  am I right?

    2. as here(link below) connect-ExoPssession commandlet is from "CreateExoPSSession.ps1" this script is installed upon installing the exchange online powerhsell module from here https://outlook.office365.com/ecp/

    if we look at the CreateExoPSSession.ps1 script it does the same New-ExoPSsession (without basic authtication) and import this session and execute the command 

    can you please share any sample for EXO v2 Module , does this causes authentication code generated upon executing the command let ?

    https://gallery.technet.microsoft.com/Connect-to-Exchange-Online-7d7365e0?ranMID=24542&ranEAID=je6NUbpObpQ&ranSiteID=je6NUbpObpQ-bdukHHRmIGvAqQCPenUehw&epi=je6NUbpObpQ-bdukHHRmIGvAqQCPenUehw&irgwc=1&OCID=AID2000142_aff_7593_1243925&tduid=(ir__tgoefbiorwkfrjuzkk0sohzz0n2xgdxpyvbwvn2e00)(7593)(1243925)(je6NUbpObpQ-bdukHHRmIGvAqQCPenUehw)()&irclickid=_tgoefbiorwkfrjuzkk0sohzz0n2xgdxpyvbwvn2e00


    I think these are the two ways to achieve exchange online command lets execution without Basic Authentication - please confirm on this 

    https://docs.microsoft.com/en-us/powershell/exchange/exchange-online/exchange-online-powershell-v2/exchange-online-powershell-v2?view=exchange-ps

    https://docs.microsoft.com/en-us/powershell/exchange/exchange-online/connect-to-exchange-online-powershell/mfa-connect-to-exchange-online-powershell?view=exchange-ps


    Arathi




    I'm not really sure what you are asking, but if you want to load the V2 module in a script, you can use this:

    https://ehloergosum.com/2019/11/06/leveraging-the-new-v2-exo-powershell-module-in-a-script/

    Monday, December 9, 2019 11:53 AM
    Moderator
  • yes exactly what I meant two ways to achieve modern authentication with exchange online command lets 

    version V1 and version V2 , there is no MFA meaning no authentication code generated to pass though 

    https://docs.microsoft.com/en-us/powershell/exchange/exchange-online/exchange-online-powershell-v2/exchange-online-powershell-v2?view=exchange-ps

    https://docs.microsoft.com/en-us/powershell/exchange/exchange-online/connect-to-exchange-online-powershell/mfa-connect-to-exchange-online-powershell?view=exchange-ps

    do you know how exactly this works internally when this EXO module is loaded and executed the commnadlets ex: Get-MailBox


    Arathi

    Tuesday, December 10, 2019 3:29 AM
  • Hi Arathij,

    1. Here are two way which used to connect to Exchange online:

    (v1) Connect to Exchange online with Basic: Connect to Exchange Online

    (v1) Connect to Exchange online with MFA: Connect to Exchange Online PowerShell by using MFA

    Connect to Exchange online with v2 module: Connect to Exchange Online using the EXO V2 module 

    2. Yes, the second and third are the same which more safer than the first one.

    3. MFA(multi-factor authentication). Without MFA, we can use account and password to verify an account directly. After enabling MFA, when verify an account, we should use an additional way to verify account after using password.

    So, after using password, if there exist another pop-up, it mean you are using MFA. (You need to enable it from Office 365 admin center first)

    Regarding how MFA behaves, you can check it from another thread.

    Regards,

    Kyle Xu


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    Tuesday, December 10, 2019 7:59 AM
    Moderator
  • Hi Arathi,

    You can check below link for connecting Exchange Online PowerShell using EXO V2 module (with MFA and Non-MFA accounts).

    Connect to Exchange Online PowerShell using EXO V2 Module.

    I hope this will help you.

    Thursday, December 12, 2019 6:10 AM
  • Hi Arathij,

    I am writing here to confirm with you how thing going now?

    If the above suggestion helps, please be free to mark it as an answer for helping more people.

    Regards,

    Kyle Xu


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    • Marked as answer by Arathij Monday, December 16, 2019 8:42 AM
    Monday, December 16, 2019 8:38 AM
    Moderator
  • Hi , 

    I am trying to execute the commandlet with the already opened runspace and session through C# after some time there is ERROR while executing the Get-Mailbox command let in the same runspace 

    is it because the session got expired ( but still the run space is available ) let me know how to solve this 

    Exception calling "GetSteppablePipeline" with "1" argument(s): "Exception calling "PromptForCredential" with "4" argument(s): "A command that prompts the user failed because the host program or the command type does not support user interaction. The host was attempting to request confirmation with the following message: Enter your credentials for https://outlook.office365.com/PowerShell-LiveID?BasicAuthToOAuthConversion=true.""


    Arathi

    Wednesday, December 18, 2019 6:14 AM
  • Hi Arathij,

    Our forum mainly deals with issues of Exchange itself, we don't familiar C#. Here is a forum for Exchange development, you can try to post your question in it, you may get suitable reply from it.

    Regards,

    Kyle Xu


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    Wednesday, December 18, 2019 8:25 AM
    Moderator