Skip to content

Commit 0e6faa2

Browse files
Update FreeBusyChecker.ps1
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.
1 parent 3fd8463 commit 0e6faa2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Diagnostics/FreeBusyChecker/FreeBusyChecker.ps1

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ This cmdlet will run the Free Busy Checker Script for Exchange On-Premises Avail
7474
#>
7575
#region Properties and Parameters
7676

77-
#Requires -Module ExchangeOnlineManagement
7877
#Requires -Module ActiveDirectory
7978

8079
[CmdletBinding(DefaultParameterSetName = "FreeBusyInfo_OP", SupportsShouldProcess)]
@@ -119,6 +118,14 @@ begin {
119118
$Script:Server = hostname
120119
$Script:startingDate = (Get-Date -Format yyyyMMdd_HHmmss)
121120
$Script:htmlFile = "$PSScriptRoot\FBCheckerOutput_$($Script:startingDate).html"
121+
#Check if EXO module is not installed, if so, Import it.
122+
if (-not $Org -or ($Org -eq 'ExchangeOnline')) {
123+
if (-not (Get-Module -ListAvailable -Name ExchangeOnlineManagement)) {
124+
Write-Error "The ExchangeOnlineManagement module is required but not installed.
125+
Install it with: Install-Module ExchangeOnlineManagement"
126+
return
127+
}
128+
Import-Module ExchangeOnlineManagement -ErrorAction Stop}
122129

123130
loadingParameters
124131
#Parameter input

0 commit comments

Comments
 (0)