If you don’t have a valid use of DirectSend in Exchange Online, Microsoft recommends that you disable it with this Exchange Online PowerShell cmdlet below. This is a follow-up post to our previous post “An improved approach to blocking Direct Send Abuse.”
Set-OrganizationConfig -RejectDirectSend $true
If you experience an error message “Unable to find type [short]” then it is likely related to your version of PowerShell. TL;DR you need to upgrade to version 7.
Steps to Fix:
- Install PowerShell 7 (latest version recommended – 7.4.0 or later)
- Download from: https://github.com/PowerShell/PowerShell/releases
- Module versions 3.5.0 or later require PowerShell 7.4.0 due to .NET 8.0 assembly dependencies
- Open PowerShell 7 (not Windows PowerShell)
- Look for “PowerShell 7” in your Start menu
- It will show “PS” instead of “Windows PowerShell” in the title bar
- Install/Update the Exchange Online Management module in PowerShell 7:
- Install-Module -Name ExchangeOnlineManagement -Force -Scope CurrentUser
- Connect to Exchange Online:
- Connect-ExchangeOnline
- Run your Set-OrganizationConfig command – it should work now!
Why This Happens
The type “uint” (and “short”) is not built into Windows PowerShell 5.1, but these types are available in PowerShell 7. When the Exchange Online Management module tries to use these types in its internal code, Windows PowerShell 5.1 can’t find them, resulting in the TypeNotFound error.
