delete log file after Run-Script if it's empty

This commit is contained in:
2021-10-23 13:54:04 -04:00
parent 64af4da861
commit 64e4ca1237
+7 -2
View File
@@ -149,9 +149,14 @@ Function Run-Script {
}
}
}
$LogFileContent = (Get-Content $LogFile)
## Write the log file output to the console
If ( Test-Path $LogFile ) { Get-Content -Path $LogFile | Write-Output }
Else { Write-Output "Log file not found at ""$LogFile""" }
If ( $LogFileContent ) { Write-Output $LogFileContent }
## Delete the log file if it's empty
Else { Remove-Item $LogFile -Force }
}
## Return a Powershell version object from a string