none
Reporting service script if any RRS feed

  • Question

  • 

    Reporting service script if any below items.

    Like : - complete history of the PG i.e., Latest recovery points / Data written /job status / start time / end time / time elapsed.

    Monday, August 10, 2020 3:32 PM

Answers

  • Hi Mani,

    You can use the below script. Please read the synopsis to know how to play with the parameters. 

    #########################################################################################################
    #                                                                                               
    # This script will list the DPM jobs history for all the protection group- Support only for last 30 days.
    #                                                                   
    #                               
    #.PARAMETER DPMserverName 
    #    DPM servers name from which the job history will be fetched.
    #    Default: localhost 
    #
    #.PARAMETER Days 
    #    Number of days for which the job report will be fetched. 
    #    Default: 1 day.
    #    
    #.PARAMETER Path
    #    Provide the path to which the report will be exported with name: DPMJobHistory.csv 
    #    Default: Report will not be exported. Job result will be displayed on the powershell console. 
    # 
    #.Example:   
    #    .\DPMJobs.ps1 -DPMserverName DPM2019 -Days 5 -Path c:\temp  
    #                                                                                
    # Author        : Aayoosh Moitro                                                                  
    # Script Name   : DPMJobHistory.ps1                                                            
    # Date Created  : 08/10/2020
    #
    #########################################################################################################
              
    
    param(
         [Parameter(Mandatory=$false)]
         [string]$DPMserverName=$env:computername,
         [Parameter(Mandatory=$false)]
         [int]$Days=1,
         [Parameter(Mandatory=$false)]
         [string]$Path= $null
         )
    
    $Jobs = @() 
    
    
    if(!(Connect-DPMServer -DPMServerName $DPMserverName -ErrorAction SilentlyContinue ))
    {
    Write-Host "Unable to connect to DPM Server $DPMserverName"
    }
    $PGs =Get-DPMProtectionGroup -DPMServerName $DPMserverName 
    
    foreach ($pg in $pgs)
    {
    
    $Jobs +=Get-DPMJob -ProtectionGroup $PG -From (Get-Date).AddDays(-$days) |? {$_.JobCategory -notlike '*Inventory*' -and $_.JobCategory -notlike 'LibraryRescan'} | Select @{l='JobName';e={$_.JobCategory}},
    @{l='Status';e={$_.Status}},
    @{l='ProtectionGroup';e={$_.ProtectionGroupName}},
    @{l='starttime';e={$_.starttime}},
    @{l='Endtime';e={$_.Endtime}},
    @{l='Data Transferred(MB)';e={"{0:N2}" -f ($_.Datasize/1024/1024)}},
    @{l='Duration(Mins)';e={"{0:N2}" -f ([datetime]$_.Endtime - [DateTime]$_.Starttime).totalminutes}}
    
    }
    
    if ($Path -le "")
    {
    $Jobs | ft -AutoSize
    }
    
    else 
    {
    if(!(Test-Path -Path $Path))
        {
         Write-Output "$Path does not exists, please enter a valid Path."
        }
     else
        {
    $path = $path + "\" + "DPMJobHistory.csv"
    
    Write-Host "DPM Job History for last $days days has been exported to path: $Path" -ForegroundColor Green
    
    $Jobs | Export-Csv $Path}
    }
    
    Disconnect-DPMServer -DPMServerName $DPMserverName
        

    Sample output as below:

    Thanks.
    Regards
    Aayoosh Moitro


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. This posting is provided "AS IS" with no warranties, and confers no rights.


    Monday, August 10, 2020 4:04 PM

All replies

  • Hi Mani,

    You can use the below script. Please read the synopsis to know how to play with the parameters. 

    #########################################################################################################
    #                                                                                               
    # This script will list the DPM jobs history for all the protection group- Support only for last 30 days.
    #                                                                   
    #                               
    #.PARAMETER DPMserverName 
    #    DPM servers name from which the job history will be fetched.
    #    Default: localhost 
    #
    #.PARAMETER Days 
    #    Number of days for which the job report will be fetched. 
    #    Default: 1 day.
    #    
    #.PARAMETER Path
    #    Provide the path to which the report will be exported with name: DPMJobHistory.csv 
    #    Default: Report will not be exported. Job result will be displayed on the powershell console. 
    # 
    #.Example:   
    #    .\DPMJobs.ps1 -DPMserverName DPM2019 -Days 5 -Path c:\temp  
    #                                                                                
    # Author        : Aayoosh Moitro                                                                  
    # Script Name   : DPMJobHistory.ps1                                                            
    # Date Created  : 08/10/2020
    #
    #########################################################################################################
              
    
    param(
         [Parameter(Mandatory=$false)]
         [string]$DPMserverName=$env:computername,
         [Parameter(Mandatory=$false)]
         [int]$Days=1,
         [Parameter(Mandatory=$false)]
         [string]$Path= $null
         )
    
    $Jobs = @() 
    
    
    if(!(Connect-DPMServer -DPMServerName $DPMserverName -ErrorAction SilentlyContinue ))
    {
    Write-Host "Unable to connect to DPM Server $DPMserverName"
    }
    $PGs =Get-DPMProtectionGroup -DPMServerName $DPMserverName 
    
    foreach ($pg in $pgs)
    {
    
    $Jobs +=Get-DPMJob -ProtectionGroup $PG -From (Get-Date).AddDays(-$days) |? {$_.JobCategory -notlike '*Inventory*' -and $_.JobCategory -notlike 'LibraryRescan'} | Select @{l='JobName';e={$_.JobCategory}},
    @{l='Status';e={$_.Status}},
    @{l='ProtectionGroup';e={$_.ProtectionGroupName}},
    @{l='starttime';e={$_.starttime}},
    @{l='Endtime';e={$_.Endtime}},
    @{l='Data Transferred(MB)';e={"{0:N2}" -f ($_.Datasize/1024/1024)}},
    @{l='Duration(Mins)';e={"{0:N2}" -f ([datetime]$_.Endtime - [DateTime]$_.Starttime).totalminutes}}
    
    }
    
    if ($Path -le "")
    {
    $Jobs | ft -AutoSize
    }
    
    else 
    {
    if(!(Test-Path -Path $Path))
        {
         Write-Output "$Path does not exists, please enter a valid Path."
        }
     else
        {
    $path = $path + "\" + "DPMJobHistory.csv"
    
    Write-Host "DPM Job History for last $days days has been exported to path: $Path" -ForegroundColor Green
    
    $Jobs | Export-Csv $Path}
    }
    
    Disconnect-DPMServer -DPMServerName $DPMserverName
        

    Sample output as below:

    Thanks.
    Regards
    Aayoosh Moitro


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. This posting is provided "AS IS" with no warranties, and confers no rights.


    Monday, August 10, 2020 4:04 PM
  • always been a time saver ..

    thanks mate :)

    Monday, August 10, 2020 4:30 PM