Dear All,
I'm developing HPDP daily report, able to get the result but the same job run multiple time in one day due to failure
Currently, I'm looking to get only the last result in the last 24 hours
$onlyLastEp =Get-ListSessions
foreach ($obj in $onlyLastEp) {
$obj |?{$obj.Specification } | Sort-Object EndTime -Descending | Select-Object -Property "Session Type", Specification,Status | Select-Object -First 1 | Export-Csv C:\Temp\report.csv -Append
}
this working but still getting the duplicate
available membership :
PS C:\Windows\system32> Get-ListSessions |gm
TypeName: Selected.System.Management.Automation.PSCustomObject
Name MemberType Definition
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
Duration NoteProperty System.TimeSpan Duration=00:02:51
End Time NoteProperty System.DateTime End Time=2/20/2021 7:32:54 PM
Errors NoteProperty System.Int32 Errors=0
Files NoteProperty System.Int32 Files=309
GB Written NoteProperty System.Double GB Written=1.55
Media NoteProperty System.Int32 Media=5
Mode NoteProperty System.String Mode=diff
Objects NoteProperty System.Int32 Objects=5
Queuing NoteProperty System.String Queuing=0:00
Session ID NoteProperty System.String Session ID=2021/02/20-7
Session Type NoteProperty System.String Session Type=Backup
Specification NoteProperty System.String Specification=MSSQL H_Backup
Start Time NoteProperty System.DateTime Start Time=2/20/2021 7:30:03 PM
Status NoteProperty System.String Status=Completed
Warnings NoteProperty System.Int32 Warnings=0
PS C:\Windows\system32>
PS C:\Windows\system32>
Can someone help me with this?