Files
powershell/Dennis_Scripts/Get-BCMExportStatus.ps1
2023-03-09 09:06:25 +01:00

24 lines
974 B
PowerShell

$process = Get-Process -Name "Batches_Export2DataWH" -ErrorAction SilentlyContinue
$processCount = ($process | Measure-Object).Count
if($processCount -gt 1) {
Write-Warning "Too many ($processCount) processes found with name 'BATCHES_Export2DataWH'"
}
elseif($processCount -eq 0) {
Write-Warning "No process found with name 'BATCHES_Export2DataWH'"
}
else {
$logPath = "D:\IFSBOSystem\Log\BATCHES_Export2DataWH_$($process.Id).log"
if(-not (Test-Path -Path $logPath)) { Write-Warning "Could not find logfile for process id $($process.Id) 'BATCHES_Export2DataWH_$($process.Id).log" }
else {
$content = Get-Content -Path $logPath
$lastLine = $content | Select-Object -Last 1
if($lastLine -notmatch 'BATCHES_DATA_EXPORT_STEP_END in package BATCHES : agentName = , arg1 = NonPersistent') {
Write-Warning "Export is running"
}
else {
Write-Warning "Export is complete"
}
}
}