Jump to content
Ketarin forum

System.Management.Automation error

Recommended Posts

Not able to execute a powershell command. 

I also tried copying over the latest version of automation/management dlls from other location and didn't make any difference. 




New dll versions I copied in 



I also tried to remap in app config to the correct assembly, but only got this far and figured I'd check here instead as maybe I'm completely offtrack




Link to post
Share on other sites

You nailed it. 

It was PS Version 5.0 that was needed. Might I suggest that #requires -version 5 or some type of  handling logic be specific to ensure that this exception is properly handled and notifies end users? I love being on cutting edge, but even I hadn't updated to Powershell 5.0 yet. 


Link to post
Share on other sites

Actually, I wasn't even sure about that requirement until you confirmed.


The actual command used doesn't even matter. The problem is that the older version of PS doesn't expose the "information" type output messages for retrieval, so I had to reference a newer version of PS in order to allow the feature.

I'll add a better error message for the future though.

Link to post
Share on other sites
  • 5 months later...

Hello again,

I am again trying to compile Ketarin for Linux. Trying to compile for Windows first, but can't get it to compile, because of the reference to the Information stream.

In the file "PowerShellScript.cs" at line 39 I get the error:

Error CS1061 'PSDataStreams' does not contain a definition for 'Information' and no extension method 'Information' accepting a first argument of type 'PSDataStreams' could be found (are you missing a using directive or an assembly reference?)
The code base I am using is from the "open source" link on the home page of ketarin.org, which contains the version number 1.8.7.
Ketarin.csproj contains
95    <Reference Include="System.Management.Automation, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
96      <HintPath>packages\Microsoft.PowerShell.5.ReferenceAssemblies.1.0.0\lib\net4\System.Management.Automation.dll</HintPath>
The file System.Management.Automation.dll supplied in version 1.8.7 in the Assemblies folder doesn't have a version number in its Properties. I have replaced it with a file that has 
version 6.3.9600 16406
but I still get the error.
When the binary file is built, is this DLL included in it?
The code tries to cater for older versions of the DLL which don't include the Information stream:
                    powerShell.Streams.Information.DataAdded += this.InfoDataAdded;
                catch (MissingMethodException)
                    // Only supported in PS 5.0 and higher

but I can't even compile it.

Any suggestions?



Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.