Private/Helper/Export-IntegrisLogFile.ps1

FUNCTION Write-IntegrisLogFile { 
    
    [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" 
    }

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

    New-Item -Path $ExportPath -ItemType Directory -ErrorAction SilentlyContinue | Out-Null

    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
}