Public/Init-LogFile.ps1
function Initialize-LogFile { Param( [Parameter(Mandatory=$False)] [string]$ParentFolderPath = $env:TEMP, [Parameter(Mandatory=$False)] [string]$LogFolderRel, [Parameter(Mandatory=$False)] [string]$FileName ) $logFileFolder = Join-Path $ParentFolderPath $LogFolderRel if( !( Test-Path $logFileFolder ) ) { New-Item $logFileFolder -ItemType Directory -Force | Out-Null } $Script:logFile = Join-Path $logFileFolder "$((Get-Date).ToString('yyyy-MM-dd HHmmss')).log" "$(Get-Date) New Session" | Out-File $Script:logFile -Force -Append Write-LogMessage "Initialized Logging. Path='$logFileFolder'" -Level Info Write-Output $Script:logFile } Export-ModuleMember -Function Initialize-LogFile Set-Alias -Name Init-NSLogFile -Value Initialize-NSLogFile |