KeDo_MiniHelper.psm1

$FunctionScriptName = "MiniHelper"
Write-Verbose "Import-Start| [$($FunctionScriptName)]"


# Just an easy way to add PSObject to an array
function Add2Arr($Property) { New-Object PSObject -Property $Property }

# Used for normal output - can be changed here to anything thats needed for automation and reporting #? Implemented as a last resort due to ever changing env requirements of output...
function Write-Out($in) { Write-Output $in }

# Replace unwanted characters from variable
function PrettyVar($in, $Filter = $env:PrettyRegex, $Replace = '') { ($in -replace $Filter, $Replace).trim() } # [^a-zA-Z ,.0-9-]

# Replace all except AlphaNum from var
function AlphaNumVar($in, $Filter = '[^a-zA-Z0-9]', $Replace = '_') { ($in -replace $Filter, $Replace).trim() } # [^a-zA-Z0-9]

# Get first value of array that is not $null - returns $null if not exist || Input should be sorted accordingly
function FirstNotNull ($in) { 
    if(($in | Measure-Object).Count -gt 0 ) { 
        $values = ($in | Where-Object { $null -ne $_  })
        if($values.count -eq 1) {$values} else {$values[0]}
    } else { $null }
}

Export-ModuleMember -Function *
Write-Verbose "Import-END| [$($FunctionScriptName)]"