I'm trying to write a script for the technicians and end users.
My script is the "framework" so to speak that calls packages that are written in batch scripts by other people.
Long story short, initially I wanted to get the exit codes for each batch script but couldn't manage to do that. So I ended up pulling the return codes for each batch file from the log that it creates. Which brought me here.
What I'm trying to do (maybe the wring way to do this) is create an empty array, and add the , application names, final return codes, log file location and explanation of the final return code.
My code kind of works. But I couldn't get the table to show each application on a new line. Rather it just keeps adding next to it.
Any ideas? Either with what I'm trying to do or I was initially trying to do?
Thank you everyone in advance.
$a = new-object psobject -Property
@{
AppName= ""
FinalReturnCode = ""
LogFileLocation = ""
}
$APP1 = "Adobe_Reader"
$a.Appname += $APP1
$App1Log = "C:\Logs\Adobe_Reader.log"
$a.LogfileLocation += $App1Log
$App3LogResult = Get-Content $App1Log | Where{$_ -match "Final Return Code:\s*(\d*)"}
$App1FinalReturnCode = $App1LogResult.Split("")[-2]
$a.FinalReturnCode += $App1FinalReturnCode
$APP2 = "Adobe_FlashPlayer"
$a.Appname += $APP2
$App2Log = "C:\Logs\Adobe_Flash.log"
$a.LogfileLocation += $App2Log
$App2LogResult = Get-Content $App2Log | Where{$_ -match "Final Return Code:\s*(\d*)"}
$App2FinalReturnCode = $App2LogResult.Split("")[-2]
$a.FinalReturnCode += $App2FinalReturnCode
$a | Format-Table Appname, LogFileLocation, FinalReturnCode -AutoSize