Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 541
  • Last Modified:

Display Records Based On Record Timestamp

I want to be able to display records from the last 24 hours.

This returns the last record (based on the -number l1 command), which is displayed below:
$Session = New-PSSession "AO-FS-02"
Invoke-Command -Session $Session {Import-Module AppAssurePowerShellModule}
Invoke-Command -Session $Session {Get-completedjobs -jobtype transfer -number l1 -protectedserver AO-AD-01}

Open in new window



Output (The EndTime is outputted in UTC.):
Output
The following will give me the last 5 records in table format:
$Session = New-PSSession "AO-FS-02"
Invoke-Command -Session $Session {
 Import-Module AppAssurePowerShellModule
 Get-CompletedJobs -JobType Transfer -Number l5 -ProtectedServer AO-AD-01 | 
 Format-Table -wrap `
  @{label="Status"; Width=10; e={$_.Status}},
  @{label="Job Type"; Width=11; e={$_.JobClassName}},
  @{label="End Time"; Width=30; e={$_.EndTime.AddHours(-8)}}
}

Open in new window


Output:
Output
What I would like to do is output the results in table format displaying the results from the last 24 hours.  You can see in the table format that the $_.EndTime.AddHours(-8) reformats the time into my timezone (Pacific).  This would have to be taken into consideration when trying to display the results.  

Is it possible to display records based upon time within then, or does it have to be after the fact?
0
jonathanbyers
Asked:
jonathanbyers
1 Solution
 
footechCommented:
I won't be able to test, but you should be able to filter just by adding a Where-Object.
Invoke-Command -Session $Session {Get-completedjobs -jobtype transfer -number l5 -protectedserver AO-AD-01 | Where {($_.EndTime).AddHours(-8) -gt (Get-Date).AddHours(-24)} }

Open in new window

0
 
jonathanbyersAuthor Commented:
Perfect, thanks!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now