Hi
@audrey,
Your current script, while the logic is sound and correct commands, uses unsupported methods.
Try this script: it's a little slower than the unsupported .NET calls but I believe should work on v11 and forward:
Code: Select all
$JobTypes = '0','1','2','24','28','65'
$CurrDate = Get-Date
Foreach($jt in $JobTypes){
$Last24hSess += Get-VBRSession -Type $jt | Where-Object {$_.CreationTime -gt $CurrDate.AddDays(-1) -and $_.CreationTme -lt $CurrDate} | Sort-Object -Property CreationTime -Descending
}
Foreach($ls in $Last24hSess){
Get-VBRBackupSession -Id $ls.id
}
Job Name State Start Time End Time Result
-------- ----- ---------- -------- ------
vmware-per-job (I... Stopped 11/13/2023 8:00:09 AM 11/13/2023 8:01:52 AM Warning
vmware-per-job (I... Stopped 11/13/2023 12:00:04 AM 11/13/2023 12:01:49 AM Warning
vmware-direct-obj... Stopped 11/12/2023 10:00:20 PM 11/12/2023 10:46:00 PM Warning
vmware-per-job (I... Stopped 11/12/2023 4:00:20 PM 11/12/2023 4:02:04 PM Warning
repo-object-test Stopped 11/13/2023 2:27:08 PM 11/13/2023 2:27:38 PM Success
gfs Waiting... 11/13/2023 2:27:08 PM 1/1/1900 12:00:00 AM None
tape-ps-test Stopped 11/13/2023 2:27:08 PM 11/13/2023 2:27:12 PM Success
test-job Waiting... 11/12/2023 10:00:20 PM 1/1/1900 12:00:00 AM None
vmware-per-job (I... Stopped 11/13/2023 8:00:09 AM 11/13/2023 8:01:52 AM Warning
vmware-per-job (I... Stopped 11/13/2023 12:00:04 AM 11/13/2023 12:01:49 AM Warning
vmware-direct-obj... Stopped 11/12/2023 10:00:20 PM 11/12/2023 10:46:00 PM Warning
vmware-per-job (I... Stopped 11/12/2023 4:00:20 PM 11/12/2023 4:02:04 PM Warning
repo-object-test Stopped 11/13/2023 2:27:08 PM 11/13/2023 2:27:38 PM Success
gfs Waiting... 11/13/2023 2:27:08 PM 1/1/1900 12:00:00 AM None
tape-ps-test Stopped 11/13/2023 2:27:08 PM 11/13/2023 2:27:12 PM Success
test-job Waiting... 11/12/2023 10:00:20 PM 1/1/1900 12:00:00 AM None
vmware-per-job (I... Stopped 11/13/2023 8:00:09 AM 11/13/2023 8:01:52 AM Warning
vmware-per-job (I... Stopped 11/13/2023 12:00:04 AM 11/13/2023 12:01:49 AM Warning
vmware-direct-obj... Stopped 11/12/2023 10:00:20 PM 11/12/2023 10:46:00 PM Warning
vmware-per-job (I... Stopped 11/12/2023 4:00:20 PM 11/12/2023 4:02:04 PM Warning
repo-object-test Stopped 11/13/2023 2:27:08 PM 11/13/2023 2:27:38 PM Success
gfs Waiting... 11/13/2023 2:27:08 PM 1/1/1900 12:00:00 AM None
tape-ps-test Stopped 11/13/2023 2:27:08 PM 11/13/2023 2:27:12 PM Success
test-job Waiting... 11/12/2023 10:00:20 PM 1/1/1900 12:00:00 AM None
You can see the output on the bottom and you can push the results of the second Foreach loop into some other array (declare it like $SessionData24h = @() before hand, then you can just use += within the loop to add to that array ($SessionData24h += {your code block to filter the sesssion further without brackets} )
The JobTypes are the numeric representation of the -Type flag on Get-VBRSession, but you can pass plaintext names from the Get-Help Get-VBRSession results and see the types of jobs you want to fetch. Just add them to the $JobTypes array.