Built-In scripts for Exchange Servers are a topic I don’t usually cover as they have been around for quite some time with little to no change between versions. However, I was reviewing the content of some built-in scripts this week when I ran into some interesting observations on two of the scripts. One script should have worked in Exchange 2019 and one, to be honest, should not exist in Exchange 2019 anymore. So, I figured I could share my findings and see if anyone else had run into this and if not, then explain why these are an issue.
(1) Script – Export-ModernPublicFolderStatistics.ps1
This script does not work in Exchange 2019:

The problem revolves around these code blocks:
$script:Exchange15MajorVersion = 15; $script:Exchange15MinorVersion = 0; $script:Exchange15CUBuild = 1263; $script:Exchange16MajorVersion = 15; $script:Exchange16MinorVersion = 1; $script:Exchange16CUBuild = 669;
And
$version = $server.AdminDisplayVersion; $hasMinE15Version = (($version.Major -eq $script:Exchange15MajorVersion) -and ($version.Minor -eq $script:Exchange15MinorVersion) -and ($version.Build -ge $script:Exchange15CUBuild)); $hasMinE16Version = (($version.Major -eq $script:Exchange16MajorVersion) -and ($version.Minor -eq $script:Exchange16MinorVersion) -and ($version.Build -ge $script:Exchange16CUBuild)); if (!$hasMinE15Version -and !$hasMinE16Version) { $failedServers += $server.Fqdn; }
So it seems the script was not updated for Exchange 2019 as the script was looking for valid Exchange 2013 and 2016 builds. This version check can be fixed with adjustments to allow for Exchange 2019 RTM and higher like so:
` $script:Exchange15MajorVersion = 15; $script:Exchange15MinorVersion = 0; $script:Exchange15CUBuild = 1263; $script:Exchange16MajorVersion = 15; $script:Exchange16MinorVersion = 1; $script:Exchange16CUBuild = 669; $script:Exchange17MajorVersion = 15; $script:Exchange17MinorVersion = 2; $script:Exchange17CUBuild = 196;
And
` $version = $server.AdminDisplayVersion; $hasMinE15Version = (($version.Major -eq $script:Exchange15MajorVersion) -and ($version.Minor -eq $script:Exchange15MinorVersion) -and ($version.Build -ge $script:Exchange15CUBuild)); $hasMinE16Version = (($version.Major -eq $script:Exchange16MajorVersion) -and ($version.Minor -eq $script:Exchange16MinorVersion) -and ($version.Build -ge $script:Exchange16CUBuild)); $hasMinE17Version = (($version.Major -eq $script:Exchange17MajorVersion) -and ($version.Minor -eq $script:Exchange17MinorVersion) -and ($version.Build -ge $script:Exchange17CUBuild)); if (!$hasMinE15Version -and !$hasMinE16Version -and !$hasMinE17Version) { $failedServers += $server.Fqdn; }
After those changes, the script works. When I did this, I saved the script as a new name so I knew it was one I modified. A caveat to this is that I do not know if this is supported, but I did get accurate results and experienced no PowerShell failures when running it. YMMV.
(2) DatabaseMaintSchedule.ps1
If I remember correctly, changing the maintenance schedule for a mailbox database has basically been ignored since Exchange 2013. This script is only really relevant to Exchange 2010. Since Exchange 2010 and 2019 cannot coexist, it seems pointless to have. I did notice that I could run the script and have it change the Database Maintenance Schedule and received no errors. Personally I think its time to retire or remove this script. The script has no warning or message to alert someone to this fact that this script is useless in Exchange 2019. At the very least, maybe a version check to prevent this from being run in Exchange 2019? What do you think?
Database Maintenance Schedule ignored:
Source – https://docs.microsoft.com/en-us/powershell/module/exchange/mailbox-databases-and-servers/Set-MailboxDatabase?redirectedfrom=MSDN&view=exchange-ps