Skip to content

Instantly share code, notes, and snippets.

@aymenjaz
Last active June 9, 2022 21:58
Show Gist options
  • Save aymenjaz/5c3d399ce73bbef626620e10b09466cc to your computer and use it in GitHub Desktop.
Save aymenjaz/5c3d399ce73bbef626620e10b09466cc to your computer and use it in GitHub Desktop.
This function is used ti write Log for all scripting process , personally i used it to track the job completion of my scripts
# This function is used ti write Log for all scripting process
# personally i used it to track the job completion of my scripts
# As using example : Write-LogFile "Test Message"
$Output_Dir = 'C:\Report\'
$Output_LogFile = 'Log.txt'
function Write-LogFile
{
[CmdletBinding()]
param(
[Parameter()]
[string] $Message
)
if((Test-Path $Output_Dir) -eq $false)
{
New-Item -ItemType Directory -Path $Output_Dir
}
$date = Get-Date
$Message + ' ; ' + $date | Out-File $Output_Dir$Output_LogFile -Append
}
@aymenjaz
Copy link
Author

aymenjaz commented Jun 9, 2022

as test of using : Write-LogFile 'Test Message'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment