How to get Get-TeamsProtectionPolicy function to use with Microsoft 365, since I'm getting an Exchange path error when trying to import the ExchangePowerShell module?

Brett 0 Reputation points
2024-12-31T16:36:34.5566667+00:00

Hello all,

I'm using PowerShell version 5.1.26100.2161 in case that's relevant.

What I'm trying to do:

I'm trying to use the PowerShell functions Get-TeamsProtectionPolicy and Get-TeamsProtectionPolicyRule to view a company's Teams protection policy info. However, those functions don't appear to be included in the ExchangeOnlineManagment version 3.7.0, even though some people seem to reference using that moduel for these functions.

What I initially tried:

Looking on Microsoft's website, it appears those functions are a part of the ExchangePowerShell module, so I installed it. However, when I try to run Import-Module ExchangePowerShell, it throws an error saying "import-Module : Exchange Server system variable ExchangeInstallPath missing."

This seems to be in reference to an on-premises Exchange server, which most of the environments I'd be running this in don't have, and it shouldn't be necessary for functions that are meant to be used for Microsoft 365 environments.

When I search the error online:

When I search online for if other people have had this issue, I'm seeing recommendations to manually set the Exchange install path variable. However, I don't want to have my PowerShell script automatically do this because I may run the script in environments where they actually do have an on-premises Exchange server, and I don't want the script to change that. Also, this script is meant to be run as a "read-only" script that shouldn't be making changes to a company's environment, so changing an Exchange install path variable wouldn't be acceptable.

My ultimate goal is to get access to these two Teams PowerShell functions--does anyone know what I need to do for this?

Thanks,

Brett

Microsoft 365
Microsoft 365
Formerly Office 365, is a line of subscription services offered by Microsoft which adds to and includes the Microsoft Office product line.
5,454 questions
Microsoft Teams
Microsoft Teams
A Microsoft customizable chat-based workspace.
10,633 questions
Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,683 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,725 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Xintao Qiao-MSFT 5,630 Reputation points Microsoft Vendor
    2025-01-01T02:02:18.9466667+00:00

    Hi, @Brett

    After you have successfully installed the module, you can load it by running the following command:

    Import-Module ExchangeOnlineManagement
    

    Of course, you can also skip the above steps and connect directly with the command:

    Connect-ExchangeOnline
    

    After that, you do not need to run the command: Import-Module ExchangePowerShell.

    Once you have successfully connected to exchange online as an administrator, you can run Teams PowerShell as shown below:

    User's image

    Similar cases can be viewed import-module exchangepowershell throws exchangeinstallpath missing - Microsoft Q&A


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".


Your answer

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