Skip to content

Commit ccede46

Browse files
authored
Merge pull request #2533 from MarcoLFrancisco/fix-onpremauth-changes-clean
Update AuthServerCheck, EWSVirtualDirectoryCheckOAuth, CheckIfExchang…
2 parents 25b2e41 + c68113d commit ccede46

8 files changed

Lines changed: 60 additions & 43 deletions

File tree

Diagnostics/FreeBusyChecker/FreeBusyChecker.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,11 @@ begin {
167167

168168
$Script:ExchangeOnPremLocalDomain = $ADDomain.forest
169169
if ([string]::IsNullOrWhitespace($ADDomain)) {
170-
$Script:ExchangeOnPremLocalDomain = $exchangeOnPremDomain
170+
$Script:ExchangeOnPremLocalDomain = $Script:ExchangeOnPremDomain
171171
}
172172

173-
if ($ExchangeOnPremDomain) {
174-
$Script:FedInfoEOP = Get-federationInformation -DomainName $ExchangeOnPremDomain -BypassAdditionalDomainValidation -ErrorAction SilentlyContinue -WarningAction SilentlyContinue | Select-Object *
173+
if ($Script:ExchangeOnPremDomain) {
174+
$Script:FedInfoEOP = Get-federationInformation -DomainName $Script:ExchangeOnPremDomain -BypassAdditionalDomainValidation -ErrorAction SilentlyContinue -WarningAction SilentlyContinue | Select-Object *
175175
}
176176
#endregion
177177

@@ -253,10 +253,10 @@ begin {
253253
exit
254254
}
255255
Write-Host " Connected to Exchange Online."
256-
$Script:ExoOrgRel = Get-EOOrganizationRelationship | Where-Object { ($_.DomainNames -like $ExchangeOnPremDomain ) } | Select-Object Enabled, Identity, DomainNames, FreeBusy*, TarGet*
256+
$Script:ExoOrgRel = Get-EOOrganizationRelationship | Where-Object { ($_.DomainNames -like $Script:ExchangeOnPremDomain ) } | Select-Object Enabled, Identity, DomainNames, FreeBusy*, TarGet*
257257
$Script:ExoIntraOrgCon = Get-EOIntraOrganizationConnector | Select-Object Name, TarGetAddressDomains, DiscoveryEndpoint, Enabled
258-
$Script:tarGetAddressPr1 = ("https://AutoDiscover." + $ExchangeOnPremDomain + "/AutoDiscover/AutoDiscover.svc/WSSecurity")
259-
$Script:tarGetAddressPr2 = ("https://" + $ExchangeOnPremDomain + "/AutoDiscover/AutoDiscover.svc/WSSecurity")
258+
$Script:tarGetAddressPr1 = ("https://AutoDiscover." + $Script:ExchangeOnPremDomain + "/AutoDiscover/AutoDiscover.svc/WSSecurity")
259+
$Script:tarGetAddressPr2 = ("https://" + $Script:ExchangeOnPremDomain + "/AutoDiscover/AutoDiscover.svc/WSSecurity")
260260
exoHeaderHtml
261261

262262
#endregion

Diagnostics/FreeBusyChecker/Functions/CommonFunctions.ps1

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,24 @@ function FetchEWSInformation {
2424
if (-not $Script:WebServicesVirtualDirectory -or -not $Script:WebServicesVirtualDirectoryOAuth) {
2525
$Script:WebServicesVirtualDirectory = Get-WebServicesVirtualDirectory -Server $Script:Server | Select-Object Identity, Name, ExchangeVersion, *Authentication*, *url -ErrorAction SilentlyContinue
2626
$Script:WebServicesVirtualDirectoryOAuth = $Script:WebServicesVirtualDirectory
27-
$Script:ExchangeOnPremEWS = ($Script:WebServicesVirtualDirectory.externalURL.AbsoluteUri)
27+
28+
if ([string]::IsNullOrWhiteSpace($Script:ExchangeOnPremEWS)) {
29+
$externalUrl = $Script:WebServicesVirtualDirectory |
30+
Where-Object { $null -ne $_.ExternalUrl } |
31+
Select-Object -First 1 -ExpandProperty ExternalUrl
32+
33+
if ($null -ne $externalUrl) {
34+
$Script:ExchangeOnPremEWS = $externalUrl.ToString()
35+
}
36+
}
2837
}
2938
}
3039
function CheckIfExchangeServer {
31-
$exchangeShell = Confirm-ExchangeShell
32-
if (-not($exchangeShell.ShellLoaded)) {
40+
param (
41+
[string]$Server
42+
)
43+
$exchangeServer = Get-ExchangeServer $Server -ErrorAction SilentlyContinue
44+
if (!$exchangeServer) {
3345
Write-Host "$Server is not an Exchange Server. This script should be run in Exchange Server Management Shell"
3446
exit
3547
}
@@ -42,10 +54,10 @@ function CheckParameters {
4254
if ([string]::IsNullOrWhiteSpace($Script:ExchangeOnPremLocalDomain)) {
4355
$MissingParameters += "Exchange On Premises Local Domain. Example: . 'C:\scripts\FreeBusyChecker\FreeBusyChecker.ps1' -OnPremisesUser John@Contoso.com"
4456
}
45-
if ([string]::IsNullOrWhiteSpace($exchangeOnPremDomain)) {
57+
if ([string]::IsNullOrWhiteSpace($Script:ExchangeOnPremDomain)) {
4658
$MissingParameters += "Exchange On Premises Domain. Example: -OnPremLocalDomain Contoso.local"
4759
}
48-
if ([string]::IsNullOrWhiteSpace($exchangeOnPremEWS)) {
60+
if ([string]::IsNullOrWhiteSpace($Script:ExchangeOnPremEWS)) {
4961
$MissingParameters += "Exchange On Premises EWS Virtual Directory External URL. Example: 'C:\FreeBusyChecker.ps1' -OnPremEWSUrl https://mail.contoso.com/EWS/Exchange.asmx"
5062
}
5163
if ([string]::IsNullOrWhiteSpace($Script:UserOnPrem)) {

Diagnostics/FreeBusyChecker/Functions/ExoDauthFunctions.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@
33

44
function ExoOrgRelCheck () {
55
PrintDynamicWidthLine
6-
Write-Host -ForegroundColor Green " Get-EOOrganizationRelationship | Where{($_.DomainNames -like $ExchangeOnPremDomain )} | Select Identity,DomainNames,FreeBusy*,TarGet*,Enabled"
6+
Write-Host -ForegroundColor Green " Get-EOOrganizationRelationship | Where{($_.DomainNames -like $Script:ExchangeOnPremDomain )} | Select Identity,DomainNames,FreeBusy*,TarGet*,Enabled"
77
PrintDynamicWidthLine
88
$ExoOrgRel
99
PrintDynamicWidthLine
1010
Write-Host -ForegroundColor Green " Summary - Organization Relationship"
1111
PrintDynamicWidthLine
1212
Write-Host " Domain Names:"
13-
if ($exoOrgRel.DomainNames -like $ExchangeOnPremDomain) {
14-
Write-Host -ForegroundColor Green " Domain Names Include the $ExchangeOnPremDomain Domain"
13+
if ($exoOrgRel.DomainNames -like $Script:ExchangeOnPremDomain) {
14+
Write-Host -ForegroundColor Green " Domain Names Include the $Script:ExchangeOnPremDomain Domain"
1515
$Script:tdExoOrgRelDomainNames = $exoOrgRel.DomainNames
1616
$Script:tdExoOrgRelDomainNamesColor = "green"
1717
} else {
18-
Write-Host -ForegroundColor Red " Domain Names do Not Include the $ExchangeOnPremDomain Domain"
18+
Write-Host -ForegroundColor Red " Domain Names do Not Include the $Script:ExchangeOnPremDomain Domain"
1919
$exoOrgRel.DomainNames
20-
$Script:tdExoOrgRelDomainNames = "$($exoOrgRel.DomainNames) - Domain Names do Not Include the $ExchangeOnPremDomain Domain"
20+
$Script:tdExoOrgRelDomainNames = "$($exoOrgRel.DomainNames) - Domain Names do Not Include the $Script:ExchangeOnPremDomain Domain"
2121
$Script:tdExoOrgRelDomainNamesColor = "green"
2222
}
2323
#FreeBusyAccessEnabled
@@ -50,7 +50,7 @@ function ExoOrgRelCheck () {
5050
}
5151
#TarGetApplicationUri
5252
Write-Host " TarGetApplicationUri:"
53-
$a = "FYDIBOHF25SPDLT." + $ExchangeOnPremDomain
53+
$a = "FYDIBOHF25SPDLT." + $Script:ExchangeOnPremDomain
5454
$HybridAgentTargetSharingEpr = "http://outlook.office.com/"
5555
$HATargetAutodiscoverEpr = "https://autodiscover-s.outlook.com/autodiscover/autodiscover.svc/"
5656
if ($exoOrgRel.TarGetSharingEpr -like "*resource.mailboxMigration.his.MSAppProxy.net/EWS/Exchange.asmx") {

Diagnostics/FreeBusyChecker/Functions/ExoOauthFunctions.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ function EXOIntraOrgConCheck {
1212
Write-Host -ForegroundColor Green " Summary - Online Intra Organization Connector"
1313
PrintDynamicWidthLine
1414
Write-Host -ForegroundColor White " TarGet Address Domains: "
15-
if ($Script:ExoIntraOrgCon.TarGetAddressDomains -like "*$ExchangeOnpremDomain*") {
15+
if ($Script:ExoIntraOrgCon.TarGetAddressDomains -like "*$Script:ExchangeOnPremDomain*") {
1616
Write-Host -ForegroundColor Green " " $Script:ExoIntraOrgCon.TarGetAddressDomains
1717
$Script:tdExoIntraOrgConTarGetAddressDomains = $Script:ExoIntraOrgCon.TarGetAddressDomains
1818
$Script:tdExoIntraOrgConTarGetAddressDomainsColor = "green"
1919
} else {
2020
Write-Host -ForegroundColor Red " TarGet Address Domains is NOT correct."
21-
Write-Host -ForegroundColor White " Should contain the $ExchangeOnpremDomain"
22-
$Script:tdExoIntraOrgConTarGetAddressDomains = " $($Script:ExoIntraOrgCon.TarGetAddressDomains) . Should contain the $ExchangeOnpremDomain"
21+
Write-Host -ForegroundColor White " Should contain the $Script:ExchangeOnPremDomain"
22+
$Script:tdExoIntraOrgConTarGetAddressDomains = " $($Script:ExoIntraOrgCon.TarGetAddressDomains) . Should contain the $Script:ExchangeOnPremDomain"
2323
$Script:tdExoIntraOrgConTarGetAddressDomainsColor = "red"
2424
}
2525
Write-Host -ForegroundColor White " DiscoveryEndpoint: "
@@ -56,20 +56,20 @@ function EXOIntraOrgConCheck {
5656
function EXOIntraOrgConfigCheck {
5757
Write-Host -ForegroundColor Green " Get-IntraOrganizationConfiguration | Select OnPremiseTarGetAddresses"
5858
PrintDynamicWidthLine
59-
$Script:ExoIntraOrgConfig = Get-EOOnPremisesOrganization | Select-Object OrganizationGuid | Get-EOIntraOrganizationConfiguration | Select-Object * | Where-Object { $_.OnPremiseTarGetAddresses -like "*$ExchangeOnPremDomain*" }
59+
$Script:ExoIntraOrgConfig = Get-EOOnPremisesOrganization | Select-Object OrganizationGuid | Get-EOIntraOrganizationConfiguration | Select-Object * | Where-Object { $_.OnPremiseTarGetAddresses -like "*$Script:ExchangeOnPremDomain*" }
6060
$IOConfig = $Script:ExoIntraOrgConfig | Format-List
6161
$IOConfig
6262
PrintDynamicWidthLine
6363
Write-Host -ForegroundColor Green " Summary - Exchange Online Intra Organization Configuration"
6464
PrintDynamicWidthLine
6565
Write-Host -ForegroundColor White " OnPremiseTarGetAddresses: "
66-
if ($Script:ExoIntraOrgConfig.OnPremiseTarGetAddresses -like "*$ExchangeOnpremDomain*") {
66+
if ($Script:ExoIntraOrgConfig.OnPremiseTarGetAddresses -like "*$Script:ExchangeOnPremDomain*") {
6767
Write-Host -ForegroundColor Green " " $Script:ExoIntraOrgConfig.OnPremiseTarGetAddresses
6868
$Script:tdExoIntraOrgConfigOnPremiseTarGetAddresses = $Script:ExoIntraOrgConfig.OnPremiseTarGetAddresses
6969
$Script:tdExoIntraOrgConfigOnPremiseTarGetAddressesColor = "green"
7070
} else {
7171
Write-Host -ForegroundColor Red " OnPremise TarGet Addresses are NOT correct."
72-
Write-Host -ForegroundColor White " Should contain the $ExchangeOnpremDomain"
72+
Write-Host -ForegroundColor White " Should contain the $Script:ExchangeOnPremDomain"
7373
$Script:tdExoIntraOrgConfigOnPremiseTarGetAddresses = $Script:ExoIntraOrgConfig.OnPremiseTarGetAddresses
7474
$Script:tdExoIntraOrgConfigOnPremiseTarGetAddressesColor = "red"
7575
}

Diagnostics/FreeBusyChecker/Functions/OnPremDAuthFunctions.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ function FedTrustCheck {
204204
PrintDynamicWidthLine
205205
$CurrentTime = Get-Date
206206
Write-Host -ForegroundColor White " Federation Trust Application Uri:"
207-
if ($FedTrust.ApplicationUri -like "FYDIBOHF25SPDLT.$ExchangeOnpremDomain") {
207+
if ($FedTrust.ApplicationUri -like "FYDIBOHF25SPDLT.$Script:ExchangeOnPremDomain") {
208208
Write-Host -ForegroundColor Green " " $FedTrust.ApplicationUri
209209
$Script:tdFedTrustApplicationUriColor = "green"
210210
$Script:tdFedTrustApplicationUriFL = $FedTrust.ApplicationUri

Diagnostics/FreeBusyChecker/Functions/OnPremOAuthFunctions.ps1

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,12 @@ function IntraOrgConCheck {
4949
}
5050
function AuthServerCheck {
5151
#PrintDynamicWidthLine
52-
Write-Host -ForegroundColor Green " Get-AuthServer | Select Name,IssuerIdentifier,TokenIssuingEndpoint,AuthMetadataUrl,Enabled"
52+
Write-Host -ForegroundColor Green " Get-AuthServer | Select Name, Realm, IssuerIdentifier, TokenIssuingEndpoint, AuthMetadataUrl, Enabled"
5353
PrintDynamicWidthLine
54-
$AuthServer = Get-AuthServer | Where-Object { $_.Name -like "ACS*" } | Select-Object Name, IssuerIdentifier, TokenIssuingEndpoint, AuthMetadataUrl, Enabled
54+
$AuthServer = Get-AuthServer |
55+
Where-Object { $_.Name -like "EvoSts*" } |
56+
Sort-Object Name |
57+
Select-Object -First 1 Name, Realm, IssuerIdentifier, TokenIssuingEndpoint, AuthMetadataUrl, Enabled
5558
$AuthServer
5659
$Script:tDAuthServerIssuerIdentifier = $AuthServer.IssuerIdentifier
5760
$Script:tDAuthServerTokenIssuingEndpoint = $AuthServer.TokenIssuingEndpoint
@@ -61,30 +64,30 @@ function AuthServerCheck {
6164
Write-Host -ForegroundColor Green " Summary - Auth Server"
6265
PrintDynamicWidthLine
6366
Write-Host -ForegroundColor White " IssuerIdentifier: "
64-
if ($AuthServer.IssuerIdentifier -like "00000001-0000-0000-c000-000000000000" ) {
67+
if ($AuthServer.IssuerIdentifier -like "https://sts.windows.net/$($AuthServer.Realm)/" ) {
6568
Write-Host -ForegroundColor Green " " $AuthServer.IssuerIdentifier
6669
$Script:tDAuthServerIssuerIdentifierColor = "green"
6770
} else {
6871
Write-Host -ForegroundColor Red " IssuerIdentifier appears not to be correct."
69-
Write-Host -ForegroundColor White " Should be 00000001-0000-0000-c000-000000000000"
72+
Write-Host -ForegroundColor White " Should be https://sts.windows.net/<Cloud Tenant ID>/"
7073
$Script:tDAuthServerIssuerIdentifierColor = "red"
7174
}
7275
Write-Host -ForegroundColor White " TokenIssuingEndpoint: "
73-
if ($AuthServer.TokenIssuingEndpoint -like "https://accounts.accesscontrol.windows.net/*" -and $AuthServer.TokenIssuingEndpoint -like "*/tokens/OAuth/2" ) {
76+
if ($AuthServer.TokenIssuingEndpoint -like "https://login.windows.net/common/oauth2/token*" ) {
7477
Write-Host -ForegroundColor Green " " $AuthServer.TokenIssuingEndpoint
7578
$Script:tDAuthServerTokenIssuingEndpointColor = "green"
7679
} else {
7780
Write-Host -ForegroundColor Red " TokenIssuingEndpoint appears not to be correct."
78-
Write-Host -ForegroundColor White " Should be https://accounts.accesscontrol.windows.net/<Cloud Tenant ID>/tokens/OAuth/2"
81+
Write-Host -ForegroundColor White " Should be https://login.windows.net/common/oauth2/token"
7982
$Script:tDAuthServerTokenIssuingEndpointColor = "red"
8083
}
8184
Write-Host -ForegroundColor White " AuthMetadataUrl: "
82-
if ($AuthServer.AuthMetadataUrl -like "https://accounts.accesscontrol.windows.net/*" -and $AuthServer.TokenIssuingEndpoint -like "*/tokens/OAuth/2" ) {
85+
if ($AuthServer.AuthMetadataUrl -like "https://login.windows.net/*/federationmetadata/2007-06/federationmetadata.xml" ) {
8386
Write-Host -ForegroundColor Green " " $AuthServer.AuthMetadataUrl
8487
$Script:tDAuthServerAuthMetadataUrlColor = "green"
8588
} else {
8689
Write-Host -ForegroundColor Red " AuthMetadataUrl appears not to be correct."
87-
Write-Host -ForegroundColor White " Should be https://accounts.accesscontrol.windows.net/<Cloud Tenant ID>/Metadata/json/1"
90+
Write-Host -ForegroundColor White " Should be https://login.windows.net/<Initial Tenant Domain>/FederationMetadata/2007-06/FederationMetadata.xml"
8891
$Script:tDAuthServerAuthMetadataUrlColor = "red"
8992
}
9093
Write-Host -ForegroundColor White " Enabled: "
@@ -162,7 +165,7 @@ function PartnerApplicationCheck {
162165
$Script:tdPartnerApplicationRealm = "Should be Blank"
163166
}
164167
Write-Host -ForegroundColor White " LinkedAccount: "
165-
if ($PartnerApplication.LinkedAccount -like "$exchangeOnPremDomain/Users/Exchange Online-ApplicationAccount" -or $PartnerApplication.LinkedAccount -like "$Script:ExchangeOnPremLocalDomain/Users/Exchange Online-ApplicationAccount" ) {
168+
if ($PartnerApplication.LinkedAccount -like "$Script:ExchangeOnPremDomain/Users/Exchange Online-ApplicationAccount" -or $PartnerApplication.LinkedAccount -like "$Script:ExchangeOnPremLocalDomain/Users/Exchange Online-ApplicationAccount" ) {
166169
Write-Host -ForegroundColor Green " " $PartnerApplication.LinkedAccount
167170
$Script:tdPartnerApplicationLinkedAccountColor = "green"
168171
} else {
@@ -541,6 +544,7 @@ function AutoDVirtualDCheckOauth {
541544
function EWSVirtualDirectoryCheckOAuth {
542545
Write-Host -ForegroundColor Green " Get-WebServicesVirtualDirectory -Server $($server)| Select Identity,Name,ExchangeVersion,*Authentication*,*url"
543546
PrintDynamicWidthLine
547+
FetchEWSInformation
544548
$W = $WebServicesVirtualDirectoryOAuth | Format-List
545549
$W
546550
EWSVirtualDirectoryCheckOAuthHtmlHead
@@ -623,6 +627,7 @@ function EWSVirtualDirectoryCheckOAuth {
623627
}
624628
Write-Host -ForegroundColor White " Should be True"
625629
}
630+
#PrintDynamicWidthLine
626631
Write-Host -ForegroundColor White "`n WindowsAuthentication:"
627632
if ($WebServicesVirtualDirectoryOauth.WindowsAuthentication -eq "True") {
628633
foreach ( $ser in $WebServicesVirtualDirectoryOauth) {

Diagnostics/FreeBusyChecker/Functions/hostOutput.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ function ShowParameters() {
5858
Write-Host -ForegroundColor White " AD root Domain"
5959
Write-Host -ForegroundColor Green " $Script:ExchangeOnPremLocalDomain"
6060
Write-Host -ForegroundColor White " Exchange On Premises Domain: "
61-
Write-Host -ForegroundColor Green " $exchangeOnPremDomain"
61+
Write-Host -ForegroundColor Green " $Script:ExchangeOnPremDomain"
6262
Write-Host -ForegroundColor White " Exchange On Premises External EWS url:"
63-
Write-Host -ForegroundColor Green " $exchangeOnPremEWS"
63+
Write-Host -ForegroundColor Green " $Script:ExchangeOnPremEWS"
6464
Write-Host -ForegroundColor White " On Premises Hybrid Mailbox:"
6565
Write-Host -ForegroundColor Green " $Script:UserOnPrem"
6666
Write-Host -ForegroundColor White " Exchange Online Mailbox:"
@@ -83,7 +83,7 @@ function hostOutputIntraOrgConEnabled($Auth) {
8383
Write-Host -ForegroundColor White " -> Running for OAuth only as OAuth takes precedence over DAuth;"
8484
Write-Host -ForegroundColor White "`n This script can be Run using the -Auth All parameter to Check for both OAuth and DAuth configuration. `n `n Example: ./FreeBusyChecker.ps1 -Auth All"
8585
Write-Host -ForegroundColor White "`n This script can be Run using the -Auth DAuth parameter to Check for DAuth configuration only. `n `n Example: ./FreeBusyChecker.ps1 -Auth DAuth"
86-
lookupMethodDAuthHtml
86+
lookupMethodOAuthHtml
8787
}
8888
if ($Auth -like "All") {
8989
lookupMethodCheckAllHtml

0 commit comments

Comments
 (0)