Forum Discussion
UShort Error with the Exchange Module
Hello everyone,
For the past few days New-DkimSigningConfig has outputted this error:
Unable to find type [ushort]
The error was reproduced the following way with PowerShell:
Connect-ExchangeOnline
(Multiple different tenants with global admin access tried just in case)
New-DkimSigningConfig -DomainName example.com -Enabled $true
(Example.com is a placeholder for an actual verified domain in a given tenant)
Separate and different Windows setups with clean PowerShell and module installations have also been tried to no avail. Everything was working fine a couple days ago.
What is going on? How can one fix this?
Thanks
8 Replies
- ise-msCopper Contributor
Just as an update, as of today I was able to issue Rotate-DkimSigningConfig from within Powershell 5.1 using ExchangeOnlineManagement 3.7.0. While the command is loaded remotely it seems Microsoft has done some fixes on their end?
However the support experience has been really bad IMO:
Github was not the right place. Microsoft Support when contacted as indicated in their documentation, wanted to register a screen recording given the exact steps on how to reproduce the issue. They tried nudging me into sending a "feedback" on their documentation pages instead of acknowledging the issue and wanted me to accept closing the ticket several times while the issue wasn't fixed.
- LainRobertsonSilver Contributor
This is just an aside to point out what is impacted by this bug - and it is a bug:
- New-DkimSigningConfig
- Rotate-DkimSigningConfig
In both cases, they are incorrectly declaring the KeySize parameter as follows, where [ushort] is invalid:
[ValidateSet('1024','2048')] [ushort] ${KeySize}
Cheers,
Lain
- Arnaud_KCopper Contributor
- LainRobertsonSilver Contributor
That seems like an Exchange bug.
ushort only pertains to Visual Basic, whereas PowerShell is aligned to C# and the Common Language specification, in which there is no ushort.
If you have premier field support (PFS) or some other channel to report it directly to Microsoft, you should probably do so.
To get by in the interim - assuming this is occurring on the latest release, you might want to try removing the version you have installed and backdate to a previous version. Conversely, if you're on an older version, try updating to the latest.
If this fails, then the issue is within the dynamic module that the installed module pulls down during the call made with Connect-ExchangeOnline, in which case perhaps there is no workaround and you just have to wait for the fix, which is why lodging a bug via PFS is important.
You might also want to ask this question in the Exchange forum, as this isn't strictly a PowerShell issue and more people there would work with Exchange (you'd hope, anyway).
Edited to add the following:
I've just given the commandlet a quick try and the bug is unfortunately in the dynamically-loaded code as evidenced below. So, you'd have to go via PFS for this one.
Perhaps a dependency was missed or something in a recent update - no idea, but there's nothing you can do to fix this one, I suspect.
Edited again to correct myself:
[ushort] exists in C# but it's correct that it's not in the CLS, and certainly not natively in PowerShell as a result.
Cheers,
Lain
- GattusoDECopper Contributor
Install Powershell 7.x and try again:
Source:
https://lukasz.de/powershell-microsoft-365/fehlerbehebung-bei-der-dkim-einrichtung-in-microsoft-365-clientfehler-ex43c0ac/- LainRobertsonSilver Contributor
That's fine as an individual workaround but it doesn't absolve the need for fixing the bug. It doesn't serve as a reliable, scalable workaround as PowerShell does not ship with Windows and getting customer acceptance for mass deployments of any kind in large change-managed environments is not always trivial.
But this is missing the point. From the following article:
"All versions of the module are supported in Windows PowerShell 5.1."
ushort (and other types) are not supported by .NET Framework meaning it should not have been used if the module is indeed intended to operate under both .NET/PowerShell environments. Rather, the UInt16 type (to which ushort is mapped during compilation in the C# context) should have been used, as it is supported by both Core and Framework.
PowerShell
Windows PowerShell
This is a clear-cut bug on those two commandlets that needs fixing (and it's a very, very easy fix).
Cheers,
Lain