0

I am creating a package that will be deployed via MECM (SCCM). The Program inside the package is a Powershell script.

When the program fails, I want an error message or execption to be displayed in the Console in MECM. Right now, it can only show 0 (success) or 1 (failure).

To do this, I am trying to call InstallStatusMIF, as described here: https://learn.microsoft.com/en-us/mem/configmgr/develop/reference/core/servers/manage/installstatusmif-function

"The InstallStatusMIF function creates a status Management Information Format (MIF) file that Configuration Manager uses to correlate the install status for an advertisement."

However, the example only shows how to call the function from C++, but I am using Powershell.

I have tried with this Powershell code:

$AssemblyPath = "C:\Windows\system32\ismif32.dll"
$bytes = [System.IO.File]::ReadAllBytes($AssemblyPath)
[System.Reflection.Assembly]::Load($bytes) 

But I get the error 'Exception calling "Load" with "1" argument(s): "Bad IL format."'

If I switch to the 32 bit version of Powershell, I get the error:

Exception calling "Load" with "1" argument(s): "Could not load file or assembly '24496 bytes loaded from Anonymously Hosted DynamicMethods Assembly, Version=0.0.0.0, Cultur
e=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format."

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : BadImageFormatException

Am I on the right track? How do I call the function from Powershell?

Rugbrød
  • 101
  • 3

0 Answers0