Let’s Encrypt PowerShell script fails reading MDaemon.ini - Add-Type / GetPrivateProfileString BadImageFormatException
-
Hi all,
We had an issue where MDaemon stopped updating its Let’s Encrypt SSL certificate automatically.
The failure was not DNS, ACME validation, or the certificate itself. The script was failing before renewal because it could not read valid MDaemon
.inivalues.The key error was:
Add-Type : Could not load file or assembly ... BadImageFormatExceptionThis occurred inside the script’s
Get-PrivateProfileStringhelper, which usesAdd-Typeand the Windows APIGetPrivateProfileStringcall to read INI values.After that failed, values such as the PEM path and state path came back empty/null, leading to later errors such as:
Cannot bind argument to parameter 'Path' because it is null Cannot bind argument to parameter 'Path' because it is an empty stringIn our case, the MDaemon registry values and INI file were valid. For example:
D:\MDaemon\App\MDaemon.ini PEM=D:\MDaemon\PEM\PowerShell was confirmed as 64-bit:
[Environment]::Is64BitProcess True $PSHOME C:\Windows\System32\WindowsPowerShell\v1.0As a workaround, we replaced the
Get-PrivateProfileStringfunction with a pure PowerShell INI parser instead of usingAdd-Type. After that, the script correctly read the MDaemon paths, renewed the Let’s Encrypt certificate, and applied/uploaded the SSL successfully.This looks like a robustness issue in the Let’s Encrypt PowerShell script: if the
Add-Typebased INI reader fails, the script reports downstream path/null errors even though the MDaemon configuration is valid.Has anyone else seen this with recent Windows/PowerShell environments, or is there an updated MDaemon Let’s Encrypt script that avoids this
Add-Type/GetPrivateProfileStringissue?
-
-