Script not outputting properly need help

Welcome Forums General PowerShell Q&A Script not outputting properly need help

Viewing 2 reply threads
  • Author
    Posts
    • #196820
      Participant
      Topics: 22
      Replies: 75
      Points: 367
      Rank: Contributor

      Wrote this script to check Veeam Backup Copy Jobs

      My issue is I can not get the LastResult to display properly

       

      $name = $args[0]
      
      if ((Get-PSSnapin -Name VeeamPSSNapin -ErrorAction SilentlyContinue) -eq $null)
      
      {
      
      Add-PSSnapin VeeamPSSNapin
      
      }
      
      $JobNames = Get-VBRJob -Name $name
      
      foreach ($JobName in $JobNames) {
      
      $Job = Get-VBRJob -name $JobName.Name
      
      $LastSession = $Job.FindLastSession()
      
      $Name = $Job.Name
      
      $Status = $LastSession.State
      
      $Progress = "$($LastSession.BaseProgress)%"
      
      $LastResult = Get-VBRBackupSession | Where {$_.jobId -eq $job.Id.Guid} | Sort EndTimeUTC -Descending | Select -First 1 result
      
      }
      
      write-host $Name $Status $Progress $LastResult
      exit 0  #success

      When I run this script this is my results

      PS C:\program files\nsclient++\scripts\powershell> .\check_veeam_backups.ps1 "cucm_storeonce-backupcopy"
      CUCM_StoreOnce-BackupCopy Idle 33% @{Result=Success}

      I would like to see

      CUCM_StoreOnce-BackupCopy Idle 33% Success

       

      Any ideas?

       

      Thank you

      Tom

      • This topic was modified 2 weeks, 2 days ago by Tom Grassi.
    • #196832
      Participant
      Topics: 5
      Replies: 285
      Points: 213
      Helping Hand
      Rank: Participant

      Try this.

      $LastResult = Get-VBRBackupSession | Where {$_.jobId -eq $job.Id.Guid} |
      Sort EndTimeUTC -Descending | Select -First 1 -ExpandProperty result
      }
      
      
    • #196838
      Participant
      Topics: 22
      Replies: 75
      Points: 367
      Rank: Contributor

      Thank you

      Now working great.

Viewing 2 reply threads
  • You must be logged in to reply to this topic.