Skip to content

Instantly share code, notes, and snippets.

@vScripter
Created September 5, 2017 18:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vScripter/875d57a8b453e2a1661f83f7f9c2be46 to your computer and use it in GitHub Desktop.
Save vScripter/875d57a8b453e2a1661f83f7f9c2be46 to your computer and use it in GitHub Desktop.
PROCESS {
if (-not (Test-Path -LiteralPath $filePath -PathType Leaf)) {
try {
Write-Verbose -Message 'Creating worklog file'
New-Item -Path $filePath -Type File -ErrorAction 'Stop' | Out-Null
Write-Verbose -Message 'Adding message to Work Log'
Write-Output -InputObject '## Work Log ' | Out-File -LiteralPath $filePath -Append
Write-Output -InputObject "### $nowLong" | Out-File -LiteralPath $filePath -Append
Write-Output -InputObject ' ' | Out-File -LiteralPath $filePath -Append
Write-Output -InputObject '* ' | Out-File -LiteralPath $filePath -Append
if (Test-Path -LiteralPath $filePath -PathType Leaf) {
Write-Verbose -Message 'Work Log file created successfully'
} else {
Write-Verbose -Message 'Work Log file not created'
} # end if/else Test-Path
} catch {
Write-Warning -Message "Error creating work log file. $_"
} # end try/catch
} else {
Write-Warning -Message 'Worklog for today had already been created'
} # end if/else
} # end PROCESS block
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment