Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/wrong variable and regex #8

Merged
merged 4 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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."
}
Loading