Created
September 5, 2017 18:27
-
-
Save vScripter/875d57a8b453e2a1661f83f7f9c2be46 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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