Private/Helper/Export-IntegrisOutputLog.ps1

FUNCTION Export-IntegrisOutputLog { 
    
    [CmdletBinding()]
    PARAM (
        [Parameter(Mandatory)]
        $Object,
        [STRING]$OutputPath = $ModuleExportDir,
        [STRING]$OutputFolder = ((Get-PSCallStack)[(Get-PSCallStack).Count-2].Command),        
        [STRING]$ExtraPath = $null,
        [STRING]$FileName = $OutputFolder
    )


    IF ($ExtraPath) { $ExportPath = "$ModuleExportDir\$OutputFolder\$ExtraPath" } 
    ELSE {$ExportPath = "$ModuleExportDir\$OutputFolder" }

    IF ($FileName) { 
        $FileName = ($FileName -split '\.')[0]
        $ExportPath += "\$FileName $((Get-Date).ToString(""yyy_MM_dd HH_mm_ss"")).csv" 
    }
    ELSE { $ExportPath += "\$OutputFolder $((Get-Date).ToString(""yyy_MM_dd HH_mm_ss"")).csv" }

    $ExportPath = $ExportPath.Replace("\\","\")

    $Object | Export-CSV -Path $ExportPath
}