g00p3k Posted April 29, 2016 Report Share Posted April 29, 2016 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 comment Share on other sites More sharing options...
shawn Posted April 29, 2016 Report Share Posted April 29, 2016 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. Link to comment Share on other sites More sharing options...
Etz Posted April 30, 2016 Report Share Posted April 30, 2016 Write-Host would write into "log" window. And I would avoid replacing dll`s as there may be changes between those. Link to comment Share on other sites More sharing options...
floele Posted April 30, 2016 Report Share Posted April 30, 2016 Which version of PowerShell do you have installed? You probably need version 5 to run the script properly. Link to comment Share on other sites More sharing options...
g00p3k Posted May 2, 2016 Author Report Share Posted May 2, 2016 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. Link to comment Share on other sites More sharing options...
g00p3k Posted May 2, 2016 Author Report Share Posted May 2, 2016 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. Link to comment Share on other sites More sharing options...
g00p3k Posted May 2, 2016 Author Report Share Posted May 2, 2016 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 comment Share on other sites More sharing options...
floele Posted May 3, 2016 Report Share Posted May 3, 2016 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 comment Share on other sites More sharing options...
floele Posted May 8, 2016 Report Share Posted May 8, 2016 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. Link to comment Share on other sites More sharing options...
JimH44 Posted October 26, 2016 Report Share Posted October 26, 2016 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? Link to comment Share on other sites More sharing options...
floele Posted October 30, 2016 Report Share Posted October 30, 2016 I think you need this: https://blogs.msdn.microsoft.com/powershell/2015/12/11/powershell-sdk-reference-assemblies-available-via-nuget-org/ (version 5) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now