Created
April 27, 2017 12:30
-
-
Save krnese/ab4761466e837c90b0dd79374cf8de95 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Getting Backup Jobs | |
# Constructing the BackupJobs collection | |
$uri = "https://management.azure.com" + $vault.id + "/backupJobs?api-version=2015-11-10" | |
$restResult = Invoke-RestMethod -method Get -headers $authHeader -uri $URI | |
$backupJobs = $restResult.value | |
$backupJobs = $backupJobs.Properties | |
$resourceGroupName = $vault.id.Split('/') | |
$resourceGroupName = $resourceGroupName[4] | |
$newJobs = (get-date).AddHours(((-1))).ToUniversalTime().ToString('yyyy-MM-ddtHH:mm:ssZ') | |
# Getting all the recent Backup Jobs for the selected Vault and sending it to OMS Log Analytics | |
foreach ($backupJob in $backupJobs) | |
{ | |
if ($backupJob.startTime -gt $newJobs) | |
{ | |
$backupJobTable = @() | |
$backupJobData = New-Object psobject -property @{ | |
JobName = $backupJob.jobType; | |
Status = $backupJob.status; | |
Duration = $backupJob.duration; | |
TargetName = $backupJob.entityFriendlyName; | |
Operation = $backupJob.operation; | |
StartTime = $backupJob.startTime; | |
EndTime = $backupJob.endTime; | |
BackupType = $backupJob.backupManagementType; | |
LogType = 'BackupJobs'; | |
VMVersion = $backupJob.virtualMachineVersion; | |
ResourceGroupName = $resourceGroupName; | |
Location = $vault.location; | |
VaultName = $vault.name; | |
SubscriptionId = $azureSubscriptionId; | |
JobId = $backupJob.activityId | |
} | |
$backupJobTable += $backupJobData |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment