Closed Cris70 closed 6 years ago
I get the same error when using PS 4.0. When I test on a machine that has PS 5.1, it works fine. I think it has to do with the change to the enums in commit e6f4ed1ea2cfbeedad7e2ef3f880250aa5db4aba. If I edit Send-SyslogMessage.ps1 and put the Add-Type -TypeDefinition lines back in, then I'm able to run it from PS 4.0 successfully.
Hi,
Thanks for reporting the issue.
I am guessing when you referred to "released version" you mean the PowerShell Gallery? That should match the GitHub version.
It certainly looks like the changes to the enums have caused an issue.
I have reverted the enum changes, and the Pester tests are now passing.
I have just pushed version 3.1 to this repository. Could you both test and confirm that this is now working as expected?
Once you confirm, I will push the new version to the PowerShell Gallery.
Hi @kjacobsen
I am guessing when you referred to "released version" you mean the PowerShell Gallery? That should match the GitHub version.
No, I was referring to v2.0.1 that you get when you click on the "release" header here on GitHub. It is from 2015 and it is the last one released here.
I'll download the new master and I'll let you know. Thank you!
Hi @Cris70,
I haven't been keeping on top of those, I will try to include those into my CI/CD processes from now on. I actually didn't realise anyone was using those!
I have created a release based upon this version to assist in testing.
@kjacobsen unfortunately I still get the same error.
I copied the files from v3.1 over the previous files. Do I need to do something to have powershell load the new files?
To me, it seems powershell is seeing the correct release of the code, because:
PS C:\ServizioDB> get-module Posh-SYSLOG
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 3.1.0 Posh-SYSLOG Send-SyslogMessage
Also the error is now on a different line, but the message is the same:
PS C:\ServizioDB> .\CreaRilascioNew.ps1
An error has occured!
Multiple ambiguous overloads found for ".ctor" and the argument count: "1".
At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Posh-SYSLOG\functions\Send-SyslogMessage.ps1:85 char:5
+ [OutputType($null)]
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : MethodCountCouldNotFindBest
Cris
Why does that seem to make me think that it is an issue with the Output type? The error line is line 85, well after the enum definitions (which also wouldn't work in 4.0).
Can you try removing the line [OutputType($null)]
from Send-SyslogMessage.ps1?
Still error, but different now:
PS C:\ServizioDB> .\CreaRilascioNew.ps1
An error has occured!
Send-SyslogMessage : Multiple ambiguous overloads found for ".ctor" and the argument count: "1".
At C:\ServizioDB\CreaRilascioNew.ps1:109 char:3
+ Send-SyslogMessage -Server localhost -Message $msg -Severity $severity -Facili ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Send-SyslogMessage], MethodException
+ FullyQualifiedErrorId : MethodCountCouldNotFindBest,Send-SyslogMessage
Row 109 in my code is:
Send-SyslogMessage -Server localhost -Message $msg -Severity $severity -Facility user;
Cris
Hi,
How are you loading the module?
Sorry, I forgot to mention in my original message that I did have to comment out the "[OutputType($null)]" lines in most of the ps1 files. That is the cause of the error that @Cris70 is getting. I've not used the OutputType before, and I tried playing around with it, but haven't gotten it to work yet. It does work on PS 5 though.
I also forgot that I was playing around with my username that night and didn't change it back before posting. So you'll see this from my real username this time.
@kjacobsen Thanks for the great module!
@kjacobsen @bnapolitano after commenting out ALL the instances of "[OutputType($null)]" everything is now working!! Thank you both for your help and for a great module!!
Thanks to both of you!!
As the output time isn't that important, I will remove it, and push out a new version shortly.
Quick update.
I have pushed version 3.1.1 out to both GitHub (https://github.com/poshsecurity/Posh-SYSLOG/releases/tag/3.1.1) and PowerShell Gallery.
I want to thank you both for your assistance with this one, it is very much appreciated.
Looks like this bug has reappeared from the quick analysis of #15
Hi,
This issue should now be resolved.
Hi, I've been using the released version for quite a while, but now I see that the master version is quite advanced. However, when I try to use it in my project, I get this:
By looking at line 81 I do not find anything resembling ".ctor". Where is the problem? Am I missing something?
Thank you in advance. Cris