From cbef3ea79d3f818ee0bac7fd1fa1d8462410366d Mon Sep 17 00:00:00 2001 From: David Yoder Date: Fri, 23 Feb 2024 11:52:57 -0500 Subject: [PATCH] delete existing reports with same name --- Create-BatteryReport.ps1 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Create-BatteryReport.ps1 b/Create-BatteryReport.ps1 index 64a0ae6..e3108fa 100644 --- a/Create-BatteryReport.ps1 +++ b/Create-BatteryReport.ps1 @@ -12,6 +12,10 @@ $ReportPathNoExt = "${OutputDirectory}\batteryreport_${Env:COMPUTERNAME}_${Today $HtmlReportPath = $ReportPathNoExt + '.html' $XmlReportPath = $ReportPathNoExt + '.xml' +# Delete reports if they already exist +If ( Test-Path $XmlReportPath ) { Remove-Item -Path $XmlReportPath -Force } +If ( Test-Path $HtmlReportPath ) { Remove-Item -Path $HtmlReportPath -Force } + # Generate the XML report Write-Output "Generating XML battery report: ${XmlReportPath}" Try { Start-Process "powercfg.exe" -ArgumentList "/batteryreport /output ""${XmlReportPath}"" /xml" -Wait }