Share via

EXOPowerShell module use in multiple user profiles

Mueller, Jim 1 Reputation point
2022-07-07T14:37:24.37+00:00

Hello,

Our team uses a PowerShell script to finalize onboarding of new users. I am trying to modify the script to change it from using basic auth to modern auth. The EXO module was installed by me on the server, and I don't recall seeing an option to install it for the CurrentUser vs the entire computer for all users. When a different admin logs into the server and attempts to run the script, the following line generates an error that the file cannot be found (obviously, since the module was only installed into my profile):

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

The above line came from the following archived thread:
https://social.technet.microsoft.com/Forums/en-US/da419e14-de8d-4b35-99d7-2550eeab5d43/connect-exonline-using-window-powershell-instead-of-using-quotexchange-online-powershell-module?forum=winserverpowershell

We need multiple staff to have the ability to successfully run this script. I'd rather not depend upon a module installed into a specific user profile. How do I modify the environment and script on this server so that the module can be loaded by any profile?

Thanks!

Exchange | Hybrid management
Exchange | Hybrid management

The administration of a hybrid deployment that connects on-premises Exchange Server with Exchange Online, enabling seamless integration and centralized control.

Windows for business | Windows Server | User experience | PowerShell

1 answer

Sort by: Most helpful
  1. Vasil Michev 127K Reputation points MVP Volunteer Moderator
    2022-07-07T14:44:17.073+00:00

    That's for the old version of the module. Install the V2 one, ExchangeOnlineManagement, which you can also do in the AllUsers scope:

    Install-Module -Name ExchangeOnlineManagement -Scope AllUsers  
    

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

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.