Skip to content

Conversation

@MedElhamm0uti
Copy link

Issue:
The script cannot run on Exchange servers without the EXO module being installed even when checking only On-prem conf

Reason:
The script should still run if the -Org parameter is set to check ExOnPremise Only, e.g: Running on an exchange server with no direct outbound connection to Entra/EXO.. or where EXO module cannot be installed.

Fix:
Removed the static requirement for EXO module and replaced it with a conditional check.

Validation:
Provide if applicable

@MedElhamm0uti MedElhamm0uti requested a review from a team as a code owner September 22, 2025 13:46
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a dependency issue where the FreeBusyChecker script required the ExchangeOnlineManagement module even when checking only on-premises Exchange configurations. The fix allows the script to run on Exchange servers without the EXO module when using the -Org ExOnPremise parameter.

  • Removed the static #Requires -Module ExchangeOnlineManagement directive
  • Added conditional checking and importing of the ExchangeOnlineManagement module only when needed

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@lusassl-msft
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@dpaulson45
Copy link
Member

@MarcoLFrancisco to review

Copy link
Contributor

@MarcoLFrancisco MarcoLFrancisco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not allowed to import modules in script execution. Therefore "Import-Module ExchangeOnlineManagement -ErrorAction Stop" cant be used

image

In Exchange Online part we check if it is connected to Exchange online. A previous check can be done for Exchange Online Module and exit with write-host "Exchange Online Module not installed"

image

@dpaulson45
Copy link
Member

dpaulson45 commented Oct 16, 2025

It is not allowed to import modules in script execution. Therefore "Import-Module ExchangeOnlineManagement -ErrorAction Stop" cant be used

image In Exchange Online part we check if it is connected to Exchange online. A previous check can be done for Exchange Online Module and exit with write-host "Exchange Online Module not installed" image

@MarcoLFrancisco You can actually use Import-Module within script execution. We have it occurring in multiple scripts within this project.

Copy link
Contributor

@MarcoLFrancisco MarcoLFrancisco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved, thank you!

@MarcoLFrancisco
Copy link
Contributor

@david

It is not allowed to import modules in script execution. Therefore "Import-Module ExchangeOnlineManagement -ErrorAction Stop" cant be used
image
In Exchange Online part we check if it is connected to Exchange online. A previous check can be done for Exchange Online Module and exit with write-host "Exchange Online Module not installed"
image

@MarcoLFrancisco You can actually use Import-Module within script execution. We have it occurring in multiple scripts within this project.

Understood. Thank you for the clarification. Approved.

The script should still run if the -Org parameter is set to check ExOnPremise Only, e.g: Running on an exchange server with no direct outbound connection to Entra/EXO.. or modules cannot be installed.
@dpaulson45
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@dpaulson45
Copy link
Member

@Ghost0s please address the code formatting for the pipeline to complete.

@dpaulson45
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@dpaulson45
Copy link
Member

@Ghost0s please follow our contributing guides to get your PR to properly work and pass the build pipeline process:

https://github.com/microsoft/CSS-Exchange/blob/main/CONTRIBUTING.md

Then if you know how, please rebase your branch so there is only 1 commit on the branch you are trying to merge into ours.

@dpaulson45
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@dpaulson45
Copy link
Member

@MedElhamm0uti as I provided before, you need to follow the contributing guide to get past the build pipeline. Otherwise, this PR will not merge.

https://github.com/microsoft/CSS-Exchange/blob/main/CONTRIBUTING.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants