4

クラスから PowerShell スクリプトを実行しようとしていますが、プラットフォーム ターゲットを x86 モードに設定するとエラーが発生します。

Cannot retrieve the dynamic parameters for the cmdlet. Retrieving the COM class factory for component with CLSID {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

x86 Powershell フォルダーから取得した System.Management.Automation dll があるため、x86 で動作しない理由がわかりません

プラットフォーム ターゲットを x64 に設定すると、問題なく動作します

これが私のコードです:

 RunspaceConfiguration runspaceConfiguration = RunspaceConfiguration.Create();

        Runspace runspace = RunspaceFactory.CreateRunspace(runspaceConfiguration);
        runspace.Open();

        RunspaceInvoke scriptInvoker = new RunspaceInvoke(runspace);

        Pipeline pipeline = runspace.CreatePipeline();

        //Here's how you add a new script with arguments
        string fullPath = Path.GetFullPath(@"..\..\Scripts\CreateApplicationPool.ps1");
        Command myCommand = new Command(fullPath);


        myCommand.Parameters.Add("ApplicationPoolName", "example");

        pipeline.Commands.Add(myCommand);

        // Execute PowerShell script
        Collection<PSObject> results = pipeline.Invoke();
4

1 に答える 1