Jump to content
Ketarin forum
  • Announcements

g00p3k

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. 

 

pmxyFyJ.png

 

New dll versions I copied in 

OOF6l2a.png

 

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

 

emvgxot.png

 

Share this post


Link to post
Share on other sites

have you tried console.writeline instead, or writing your output to a file (out-file)? I suspect write-host isn't implemented in this context since there's no display.

Share this post


Link to post
Share on other sites

Write-Host would write into "log" window.

And I would avoid replacing dll`s as there may be changes between those.

Share this post


Link to post
Share on other sites

I have Powershell 4.0

Is Powershell 5.0 truly a requirement? 

That makes this lose the portable aspect for many systems that haven't yet been upgraded to this brand new PS version.

Share this post


Link to post
Share on other sites

Write-host doesn't seem to be the problem. The following simple command also failed

I reset the config file and also replaced the original dlls back in place. 

 

xxvxJsr.png

Share this post


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. 

nJQul8h.png

Share this post


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.

Share this post


Link to post
Share on other sites

I'll try to make Ketarin work with PS 4.0 by ignoring the error (which will result in no "info" output). Would be nice if someone could have a try with the latest beta.

Share this post


Link to post
Share on other sites

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=3.0.0.0, 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:
 
                try
                {
                    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?

 
 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×