It is possible to use the following MS-Powershell script to truncate the log file using the command:
powershell -ExecutionPolicy ByPass -File c:\tools\cut.ps1 <your log file location>
Where cut.ps1 is the PowerShell script below.
Example:
powershell -ExecutionPolicy ByPass -File c:\tools\cut.ps1 asbroker1.server.log
# POWERSHELL SCRIPT: cut.ps1
param( [string]$Srcfile )
If ( $Srcfile -eq "" ) {
Write-Host
Write-Host "Cut.ps1, Version 1.01"
Write-Host "Cut content of a text file"
Write-Host
Write-Host "Usage: .\cut.PS1 <File Path>\Srcfile"
Write-Host
Write-Host "Where: Srcfile is the file to be cut"
Write-Host
}
Else {
if(Test-Path "$Srcfile") {
$newlines= "--- Cut ! ---" + [DateTime]::Now.ToString("yyyy-MM-dd@HH:mm:ss")
$newlines | out-file -Force -Encoding ASCII $Srcfile
}
Else {
Write-Host "File " $Srcfile " does not exist"
}
}