I have a file which is shown as below:
DateTime: 2018-02-09 02:00:12
Database: [master]
Status: ONLINE
Mirroring role: None
Standby: No
Updateability: READ_WRITE
User access: MULTI_USER
Is accessible: Yes
Recovery model: SIMPLE
Differential base LSN: 940000000008500178
Last log backup LSN: NULL
DateTime: 2018-02-09 02:00:12
Command: DECLARE @ReturnCode int EXECUTE @ReturnCode = [master].dbo.xp_create_subdir N'J:\dump_data\sqlserver234\db_dump' IF @ReturnCode  0 RAISERROR('Error creating directory.', 16, 1)
Outcome: Succeeded
Duration: 00:00:00
DateTime: 2018-02-09 02:00:12
DateTime: 2018-02-09 02:00:12
Command: BACKUP DATABASE [master] TO DISK = N'J:\dump_data\sqlserver234\db_dump\master_FULL_20180209_020012.bak' WITH CHECKSUM, COMPRESSION
Processed 512 pages for database 'master', file 'master' on file 1.
Processed 3 pages for database 'master', file 'mastlog' on file 1.
BACKUP DATABASE successfully processed 515 pages in 0.088 seconds (45.693 MB/sec).
Outcome: Succeeded
Duration: 00:00:00
DateTime: 2018-02-09 02:00:12
DateTime: 2018-02-09 02:00:12
Command: RESTORE VERIFYONLY FROM DISK = N'J:\dump_data\sqlserver234\db_dump\master_FULL_20180209_020012.bak'
The backup set on file 1 is valid.
Outcome: Succeeded
Duration: 00:00:00
DateTime: 2018-02-09 02:00:12
DateTime: 2018-02-09 02:00:12
Database: [model]
Status: ONLINE
Mirroring role: None
Standby: No
Updateability: READ_WRITE
User access: MULTI_USER
Is accessible: Yes
Recovery model: SIMPLE
Differential base LSN: 31000001141300037
Last log backup LSN: NULL
DateTime: 2018-02-09 02:00:12
Command: DECLARE @ReturnCode int EXECUTE @ReturnCode = [master].dbo.xp_create_subdir N'J:\dump_data\sqlserver234\db_dump' IF @ReturnCode  0 RAISERROR('Error creating directory.', 16, 1)
Outcome: Succeeded
Duration: 00:00:00
DateTime: 2018-02-09 02:00:12
DateTime: 2018-02-09 02:00:12
Command: BACKUP DATABASE [model] TO DISK = N'J:\dump_data\sqlserver234\db_dump\model_FULL_20180209_020012.bak' WITH CHECKSUM, COMPRESSION
Processed 320 pages for database 'model', file 'modeldev' on file 1.
Processed 2 pages for database 'model', file 'modellog' on file 1.
BACKUP DATABASE successfully processed 322 pages in 0.048 seconds (52.256 MB/sec).
Outcome: Failed
Duration: 00:00:00
DateTime: 2018-02-09 02:00:12
DateTime: 2018-02-09 02:00:12
Command: RESTORE VERIFYONLY FROM DISK = N'J:\dump_data\sqlserver234\db_dump\model_FULL_20180209_020012.bak'
The backup set on file 1 is valid.
Outcome: Failed
Duration: 00:00:00
DateTime: 2018-02-09 02:00:12
I have written a PowerShell file which give me databasename and corresponding outcome:
param(
 [Parameter(Mandatory=$True)][string]$path  
)
#param([string]$path)
# <context>
#   <description>
#   Sending output to console
#   </description>
# </context>
try
{
    foreach($line in [System.IO.File]::ReadLines("E:\utility\TEDM_DBA_M_MNT_BACKUP_System.txt"))
    {
        $database=$line|select-string -pattern 'Database:'          
        $outcome=$line|select-string -pattern 'Outcome:'            
        Write-host $outcome
        if($outcome -eq 'Outcome: Failed')
        {
            Write-Host $outcome
        }
    }           
}
Catch
{
    Write-Host -BackgroundColor Red -ForegroundColor White "Fail" 
    $errText =  $Error[0].ToString() 
    if ($errText.Contains("network-related")) 
    {
        Write-Host "Connection Error. Check server name, port, firewall."
    }   
    Write-Host $errText 
    continue 
}
But when I am comparing string with Outcome: failed it passes for all conditions:
 if($outcome -eq 'Outcome: Failed')
What am I doing wrong in the string comparison?
 
    