Get StorageJob - PowerShell


Overview

The Get-StorageJob command in PowerShell allows you to retrieve information about storage jobs that are running or have completed within Azure Storage. It provides insights into the status, progress, and details of these jobs. Understanding these jobs is crucial for monitoring and managing storage operations, such as copying data between storage accounts or containers, and triggering other actions based on their completion.

Syntax

Get-StorageJob [-JobId] <string[]> [-AccountName] <string> [-JobType] <string[]> [-StartTime] <DateTime> [-EndTime] <DateTime> [[-Include] <string[]>] [[-Exclude] <string[]>] [-ErrorAction] <ActionPreference> [-Verbose] [-Debug] [-OutFile] <string> [-OutVariable] <string> [<CommonParameters>]

Options/Flags

  • -JobId: Specifies the ID of the storage job to retrieve information about. You can provide multiple job IDs to get details about multiple jobs.
  • -AccountName: Filters the results to include only jobs associated with the specified Azure Storage account name.
  • -JobType: Filters the results to include only jobs of the specified type(s). Valid job types include “Copy”, “IncrementalCopy”, “Delete”, and “Other”.
  • -StartTime: Limits the results to jobs that started on or after the specified date and time.
  • -EndTime: Limits the results to jobs that completed on or before the specified date and time.
  • -Include: Specifies additional properties to include in the output. Valid properties include “Blob”, “Container”, “StorageAccount”, and “SourceAccount”.
  • -Exclude: Specifies properties to exclude from the output.
  • -ErrorAction: Controls how errors are handled.
  • -Verbose: Outputs detailed information about the command’s execution.
  • -Debug: Outputs additional debugging information about the command’s execution.
  • -OutFile: Saves the output to a specified file.
  • -OutVariable: Stores the output in a specified variable.

Examples

Get details about a specific storage job:

Get-StorageJob -JobId "fa412705-41c2-4bfd-95f5-ad3702453bcc"

Get all storage jobs of a specific type:

Get-StorageJob -JobType "Copy"

Get storage jobs within a time range:

Get-StorageJob -StartTime "2023-03-01" -EndTime "2023-03-10"

Get storage jobs and include additional properties:

Get-StorageJob -Include Blob,StorageAccount

Common Issues

  • Job not found: The specified job ID may not exist or be accessible with the provided credentials.
  • Access denied: Ensure you have sufficient permissions to access the storage account where the job is running.
  • Invalid date/time format: Time and date values must be in the correct format (e.g., “yyyy-MM-dd” or “yyyy-MM-dd HH:mm:ss”).

Integration

Get-StorageJob can be integrated with other PowerShell commands to automate storage operations. For example, you can:

  • Use Get-StorageJob with Where-Object to filter the output based on specific criteria.
  • Combine Get-StorageJob with Wait-StorageJob to wait for a specific job to complete before performing subsequent actions.
  • Utilize Get-StorageJob in scripts to monitor and track the progress of storage operations.
  • New-StorageJob
  • Start-StorageJob
  • Stop-StorageJob
  • Wait-StorageJob