Private/Internal.ps1
Function Import-JsonConfig { <# .Synopsis Loads the XML Config File for Send-StatsToGraphite. .Description Loads the XML Config File for Send-StatsToGraphite. .Parameter ConfigPath Full path to the configuration XML file. .Example Import-JsonConfig -ConfigPath C:\Stats\Send-PowerShellGraphite.ps1 .Notes NAME: Convert-TimeZone AUTHOR: Matthew Hodgkins WEBSITE: http://www.hodgkins.net.au #> [CmdletBinding()] Param ( # Configuration File Path [Parameter(Mandatory = $true)] $ConfigPath ) $Config = Get-Content -Path $ConfigPath | Out-String | ConvertFrom-Json Return $Config } # http://support-hq.blogspot.com/2011/07/using-clause-for-powershell.html function PSUsing { param ( [System.IDisposable] $inputObject = $(throw "The parameter -inputObject is required."), [ScriptBlock] $scriptBlock = $(throw "The parameter -scriptBlock is required.") ) Try { &$scriptBlock } Finally { if ($null -ne $inputObject) { if ($null -eq $inputObject.psbase) { $inputObject.Dispose() } else { $inputObject.psbase.Dispose() } } } } function GetPrettyProblem { param ( $Problem ) $prettyString = (Out-String -InputObject (format-list -inputobject $Problem -Property * -force)).Trim() return $prettyString } |