Skip to content

Commit

Permalink
Merge pull request #8 from qbeyond/fix/wrong-variable-and-regex
Browse files Browse the repository at this point in the history
Fix/wrong variable and regex
  • Loading branch information
QBY-ChristianHartmann authored Feb 19, 2024
2 parents 19a7cd3 + a1ec9c1 commit 7f41068
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ All notable changes to this module will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this module adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased
## [Unreleased]

## [2.0.2] - 2024-02-19

- Fixed wrong variable name in azure query creation
- fixed typo in regex
- added errorCounter to actualle let the runbook status be "failed" if error occur

## [2.0.0] - 2023-10-17

Expand Down
16 changes: 11 additions & 5 deletions runbooks/Set-DeploymentSchedules.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ Write-Output "Following severity group tags were found $severityGroups"
Set-AzContext -Subscription $managementSubscriptionId

Write-Output "Starting creating/ updating severity groups."
$syntaxRegex = '^(0[1-9]|[1-9][0-9])-(first|second|third|forth|last)-(monday|tuesday|wednesday|thursday|friday|saturday|sunday)-([01]\d|2[0-3])([0-5]\d)-([XCSUFEDTG]+)-(reboot|neverreboot|alwaysreboot|onlyreboot)$'

$syntaxRegex = '^(0[1-9]|[1-9][0-9])-(first|second|third|fourth|last)-(monday|tuesday|wednesday|thursday|friday|saturday|sunday)-([01]\d|2[0-3])([0-5]\d)-([XCSUFEDTG]+)-(reboot|neverreboot|alwaysreboot|onlyreboot)$'
$errorCounter = 0
foreach ($severityGroup in $severityGroups) {
$splitSeverityGroup = $severityGroup -split "-"

Expand Down Expand Up @@ -137,19 +137,21 @@ foreach ($severityGroup in $severityGroups) {
}
catch {
Write-Error -Exception ($_.Exception) -Message "Could not create schedule for $severityGroup." -ErrorAction Continue
$errorCounter +=1
continue
}

try {
$azureQuery = New-AzAutomationUpdateManagementAzureQuery `
-ResourceGroupName $automationResourceGroupName `
-AutomationAccountName $automationAccountName `
-Scope $subscriptionResourceIDs `
-Scope $subscriptions `
-Tag $queryTags `

}
catch {

Write-Error -Exception ($_.Exception) -Message "Could not create azure for $severityGroup." -ErrorAction Continue
$errorCounter +=1
continue
}

Expand All @@ -167,8 +169,12 @@ foreach ($severityGroup in $severityGroups) {
}
catch {
Write-Error -Exception ($_.Exception) -Message "Could not create Update configuration for $severityGroup" -ErrorAction Continue
$errorCounter +=1
continue
}

Write-Output "Created $severityGroup successfully."
}
}
if ($errorCounter -gt 0) {
Write-Error -Message "There was an error inside the loop. Please check error messages in detailed job logs."
}

0 comments on commit 7f41068

Please sign in to comment.