How to retrieve Job action settings of Scheduler Job using Powershell

Sometimes, we may have a requirement to retrieve the job action details of your scheduled job in the Scheduler job collections using Powershell.  

There are no direct options available in PowerShell to retrieve the job action details. You need to cast the jobAction to appropriate derived class of the Action settings to retrieve the details of the action like like Uri, Storage Account,Service Bus Queue etc., 

Here is the sample PowerShell script which retrieves the details like Job Uri, Storage Account, Service Bus Queue etc.,

 PS Script:

 $schedulerJobs= Get-AzureRmSchedulerJobCollection -ResourceGroupName SchedulerIbiza -JobCollectionName testscheduler | Get-AzureRmSchedulerJob
foreach($job in $schedulerJobs) 
{
if($job.JobAction.JobActionType -eq "StorageQueue")
 {
     $jobAction = [Microsoft.Azure.Commands.Scheduler.Models.PSStorageJobActionDetails]$job.JobAction; 
     Write-Output 'Storage Account ' 
     Write-Output '----------------' 
     Write-Output  $jobAction.StorageAccount;
 }
elseif(($job.JobAction.JobActionType -eq "ServiceBusQueue") -or ($job.JobAction.JobActionType -eq "ServiceBusTopic"))
 {
     $jobActionSB = [Microsoft.Azure.Commands.Scheduler.Models.PSServiceBusJobActionDetails]$job.JobAction; 
     Write-Output 'Service Bus Queue ' 
     Write-Output '----------------  ' 
     Write-Output $jobActionSB.ServiceBusQueueName;
 }
 else
 {
    $jobActionHttp = [Microsoft.Azure.Commands.Scheduler.Models.PSHttpJobActionDetails]$job.JobAction; 
    Write-Output 'Job Name ' 
    Write-Output '-------- ' 
    Write-Output $jobActionHttp.Uri;
  }
}

Below is the sample screenshot with the result: portalimages