MattHodge / Graphite-PowerShell-Functions

A group of PowerShell functions that allow you to send Windows Performance counters to a Graphite Server, all configurable from a simple XML file.
https://hodgkins.io/using-powershell-to-send-metrics-graphite
GNU General Public License v3.0
218 stars 71 forks source link

Various Module Issues #30

Open AGirin opened 9 years ago

AGirin commented 9 years ago

Thanks a lot for a great project! I found some issues with it though:

--> I was getting no such method Dispose() on Windows 2008 with PowerShell 2.0 installed here:

function PSUsing { param ( [System.IDisposable] $inputObject = $(throw "The parameter -inputObject is required."), [ScriptBlock] $scriptBlock = $(throw "The parameter -scriptBlock is required.") ) Try { &$scriptBlock } Finally { if ($inputObject -ne $null) { if ($inputObject.psbase -eq $null) { $inputObject.Dispose() } else { $inputObject.psbase.Dispose() <-------- No such method psbase.Dispose() in PowerShell 2.0 } } } }

I had to comment that line out to make module work.

--> Module was erroring on that line with PowerShell 2.0:

RootModule = 'Graphite-Powershell.psm1'

I had to replace it with:

ModuleToProcess = 'Graphite-Powershell.psm1'

All these issues go away if I upgrade to PowerShell 3.0 though.

kasperbrandenburg commented 9 years ago

Others are commenting on the powershell version too, looks like this project requires 3.0 ... good reason to upgrade.

jdevoo commented 9 years ago

seems to be related to the implementation of PSUsing and invocations of Dispose() https://davewyatt.wordpress.com/2014/05/27/idisposable-and-powershell-versions/ Something more portable would be nice.