Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
148 commits
Select commit Hold shift + click to select a range
c2c98b6
Initial plan
Copilot Aug 30, 2025
d3ab9aa
Add SQL Agent Operator commands and initial unit tests
Copilot Aug 30, 2025
f15a1ae
Complete SQL Agent Operator commands implementation with tests
Copilot Aug 30, 2025
e8c3673
Add Enable/Disable commands and extend New/Set commands with addition…
Copilot Aug 30, 2025
72a112e
Add SMO stub enhancements and unit tests for Enable/Disable commands
Copilot Aug 30, 2025
1baefd0
Merge branch 'main' into copilot/fix-2e4f4524-bcfc-418f-abb1-7eb2a748…
johlju Sep 6, 2025
1113ccf
Fix Agent Operator test files to comply with current DSC community gu…
Copilot Sep 6, 2025
fad08ed
Remove trailing whitespace from all Agent Operator files and update P…
Copilot Sep 7, 2025
ad94ff6
Plan comprehensive fixes for Agent Operator commands and tests
Copilot Sep 7, 2025
9b89cb9
Fix verbose messages in ShouldProcess blocks and error handling
Copilot Sep 7, 2025
96328bd
Add comprehensive integration tests for all Agent Operator commands
Copilot Sep 7, 2025
f8ac585
Fix unit test parameter validation and improve mock setup
Copilot Sep 7, 2025
beab0ed
Address review comments: add Force parameter, use ErrorRecord::new(),…
Copilot Sep 7, 2025
6f98eb7
Add ::new() guideline to PowerShell Code Organization section
Copilot Sep 7, 2025
a0f71d9
Fix exception handling and unit tests for Agent Operator commands
Copilot Sep 7, 2025
d58c2ce
Update PowerShell guidelines to clarify exception handling with local…
Copilot Sep 7, 2025
3d38d09
Refactor Agent Operator error handling to use terminating errors and …
Copilot Sep 7, 2025
ed27bf6
Convert Assert-SqlDscAgentOperatorExists from private to public command
Copilot Sep 7, 2025
00b6065
Add Force parameters, parameter validation, and refactor ShouldProces…
Copilot Sep 7, 2025
36b79c8
Add begin-block validation to New-SqlDscAgentOperator and update unit…
Copilot Sep 7, 2025
44111c4
Refactor Agent Operator error handling: rename Assert function, creat…
Copilot Sep 7, 2025
96a93ea
Fix new line and whitespace
johlju Sep 7, 2025
7866747
Fix whitespace and formatting inconsistencies across multiple scripts…
johlju Sep 7, 2025
3c9d6ae
Enhance Get-AgentOperatorObject documentation: clarify behavior of Ig…
johlju Sep 7, 2025
6f9f680
Refactor Get-AgentOperatorObject tests: enhance mock setup for operat…
johlju Sep 7, 2025
57aa2f8
Refactor Get-SqlDscAgentOperator: replace direct operator retrieval w…
johlju Sep 7, 2025
dd479ce
Add Get-CommandParameters function to filter command parameters and u…
johlju Sep 7, 2025
dd30b92
Refactor Set-SqlDscAgentOperator: dynamically retrieve settable prope…
johlju Sep 7, 2025
f846486
Refactor parameter exclusion in ConvertTo-FormattedParameterDescripti…
johlju Sep 7, 2025
72e8636
Refactor parameter handling in various functions: ensure named parame…
johlju Sep 7, 2025
2979616
Refactor Get-CommandParameters function: rename to Get-CommandParamet…
johlju Sep 7, 2025
8271673
Enhance error handling in agent operator functions: set $ErrorActionP…
johlju Sep 7, 2025
12a7b83
Refactor Assert-SqlDscAgentOperator: replace Get-SqlDscAgentOperator …
johlju Sep 7, 2025
57ecaf3
Add integration tests for Assert-SqlDscAgentOperator: implement test …
johlju Sep 7, 2025
0659aa9
Enhance operator existence check in New-SqlDscAgentOperator: replace …
johlju Sep 7, 2025
e108759
Enhance error handling in New-SqlDscAgentAlert, New-SqlDscDatabase, a…
johlju Sep 7, 2025
c13f8ea
Refactor New-SqlDscAgentOperator to use static method for operator cr…
johlju Sep 7, 2025
0a1d754
Add Refresh parameter to Get-AgentOperatorObject and enhance verbose …
johlju Sep 7, 2025
562f8c3
Refactor Enable and Disable-SqlDscAgentOperator to utilize Refresh pa…
johlju Sep 7, 2025
c7f32cd
Add Refresh parameter to Test-SqlDscAgentOperator for improved operat…
johlju Sep 7, 2025
1f8a700
Add Refresh parameter to New-SqlDscAgentOperator for improved operato…
johlju Sep 7, 2025
c9c7197
Refactor Remove-SqlDscAgentOperator to utilize Get-AgentOperatorObjec…
johlju Sep 7, 2025
85de6db
Remove EmailAddress parameter from Test-SqlDscAgentOperator for clean…
johlju Sep 7, 2025
6731148
Add Test-SqlDscIsAgentOperator function and associated tests for vali…
johlju Sep 7, 2025
9234702
Refactor mock property initialization in JobServer to allow for defau…
johlju Sep 7, 2025
ed36734
Enhance Set-SqlDscAgentOperator tests to verify WhatIf behavior and e…
johlju Sep 7, 2025
9aca26c
Update New-SqlDscAgentOperator tests to include Refresh parameter and…
johlju Sep 7, 2025
71f1ed3
Refactor error handling in Assert-SqlDscAgentOperator tests to use th…
johlju Sep 7, 2025
9d898be
Fix stream redirection in build script invocation to correctly handle…
johlju Sep 7, 2025
9349d77
Set environment variable SqlServerDscCI for test isolation and cleanu…
johlju Sep 7, 2025
ab795e0
Add -ErrorAction 'Stop' to Connect-SqlDscDatabaseEngine calls for bet…
johlju Sep 7, 2025
b6dc583
Refactor credential creation for Connect-SqlDscDatabaseEngine to use …
johlju Sep 7, 2025
2e45407
Remove expected message from Should -Throw assertion for New-SqlDscAg…
johlju Sep 7, 2025
b6cf887
Add -ErrorAction 'Stop' to Get-SqlDscAgentOperator calls for improved…
johlju Sep 7, 2025
9568dcf
Add -ErrorAction 'Stop' to Get-SqlDscAgentOperator calls for improved…
johlju Sep 7, 2025
205eea4
Add -ErrorAction 'Stop' to Connect-SqlDscDatabaseEngine calls for imp…
johlju Sep 7, 2025
f02547d
Remove expected message from Should -Throw assertion for non-existent…
johlju Sep 7, 2025
90fe96b
Add -ErrorAction 'Stop' to Assert-SqlDscAgentOperator calls for impro…
johlju Sep 7, 2025
1c83116
Refine documentation for Test-SqlDscIsAgentOperator to clarify its pu…
johlju Sep 7, 2025
8f80b6e
Exclude 'Refresh' parameter from settable properties in New-SqlDscAge…
johlju Sep 7, 2025
b7092fc
Sort parameters alphabetically in ConvertTo-FormattedParameterDescrip…
johlju Sep 7, 2025
6e576bc
Enhance ConvertTo-FormattedParameterDescription to mask SecureString …
johlju Sep 7, 2025
244d12e
Optimize operator retrieval in Get-AgentOperatorObject by using direc…
johlju Sep 7, 2025
97cdec6
Update error code in Disable-SqlDscAgentOperator to align with Disabl…
johlju Sep 7, 2025
cb0d39f
Add Refresh parameter to Remove-SqlDscAgentOperator and update relate…
johlju Sep 7, 2025
9575776
Add Force parameter to New-SqlDscAgentAlert to bypass confirmation pr…
johlju Sep 7, 2025
8fd7bf6
Add Force parameter to New-SqlDscAgentAlert and update tests to inclu…
johlju Sep 7, 2025
02a61ea
Remove mock for Test-SqlDscAgentAlert in New-SqlDscAgentAlert.Tests
johlju Sep 7, 2025
6c0ae8b
Remove unused strings for Remove-SqlDscAgentOperator and Test-SqlDscI…
johlju Sep 7, 2025
b370c68
Update expected parameters for Remove-SqlDscAgentOperator test to inc…
johlju Sep 7, 2025
068ed6b
Update expected parameters for Test-SqlDscIsAgentOperator to remove E…
johlju Sep 7, 2025
c3dd9e7
Reorganize CHANGELOG.md: move 'Added' section and include new SQL Age…
johlju Sep 7, 2025
f151062
Remove redundant suppress message for PSUseDeclaredVarsMoreThanAssign…
johlju Sep 7, 2025
f7d2c46
Remove redundant suppress message for PSUseDeclaredVarsMoreThanAssign…
johlju Sep 7, 2025
00cc750
Refactor environment variable handling in integration tests to use Re…
johlju Sep 7, 2025
e1bdf49
Update examples in New-SqlDscAgentOperator to include EmailAddress pa…
johlju Sep 7, 2025
9394e50
Add EmailAddress parameter to New-SqlDscAgentOperator for test operat…
johlju Sep 7, 2025
a7044c9
Refactor New-SqlDscAgentOperator integration tests to remove redundan…
johlju Sep 7, 2025
4b81010
Refactor Get-AgentOperatorObject to use ErrorAction for error handlin…
johlju Sep 8, 2025
ddc905b
Refactor Remove-SqlDscAgentOperator to use ErrorAction parameter for …
johlju Sep 8, 2025
4000243
Enhance Remove-SqlDscAgentOperator to handle operator not found scena…
johlju Sep 8, 2025
0abd442
Refactor Remove-SqlDscAgentOperator to use ErrorActionPreference for …
johlju Sep 8, 2025
1c6e3c8
Refactor Remove-SqlDscAgentOperator to retrieve operator by name usin…
johlju Sep 8, 2025
928e976
Enhance Remove-SqlDscAgentOperator tests to verify error handling for…
johlju Sep 8, 2025
94eb03e
Enhance New-SqlDscAgentOperator tests to include email address parame…
johlju Sep 8, 2025
9e05652
Enhance New-SqlDscAgentOperator tests to clean up additional test ope…
johlju Sep 8, 2025
998eaaa
Enhance PowerShell guidelines to include return statement after Write…
johlju Sep 8, 2025
1e68f69
Add Set-SqlDscConfigurationOption command and enhance Get-SqlDscConfi…
johlju Sep 9, 2025
bef5c7f
Enable and disable Agent XPs component in Set-SqlDscAgentOperator int…
johlju Sep 9, 2025
e56a105
Enhance Remove-SqlDscAgentOperator tests by adding Parent properties …
johlju Sep 9, 2025
9e9af1a
Refactor New-SqlDscAgentOperator tests to suppress output by assignin…
johlju Sep 9, 2025
d790910
Remove redundant test for creating a new operator in New-SqlDscAgentO…
johlju Sep 9, 2025
7059b06
Refactor Assert-SqlDscAgentOperator test to suppress output by assign…
johlju Sep 9, 2025
0b0ab2e
Add -ErrorAction 'Stop' to Set-SqlDscConfigurationOption calls for im…
johlju Sep 9, 2025
34c5771
Refactor Remove-SqlDscAgentOperator tests to suppress output by assig…
johlju Sep 9, 2025
2986496
Refactor Assert-SqlDscAgentOperator tests to suppress output by assig…
johlju Sep 9, 2025
2ba05f0
Change Write-Verbose to Write-Information for improved logging in Set…
johlju Sep 9, 2025
879b9c0
Add guidance to set ConfirmImpact for ShouldProcess functions based o…
johlju Sep 9, 2025
205f708
Enhance CmdletBinding attributes by adding ConfirmImpact for improved…
johlju Sep 9, 2025
4ac3339
Add -Force parameter to Set-SqlDscConfigurationOption for Agent XPs t…
johlju Sep 9, 2025
c764e7a
Implement Force parameter handling in Set-SqlDscConfigurationOption t…
johlju Sep 9, 2025
dfc23a9
Add OutputType attribute to Set-SqlDscConfigurationOption for improve…
johlju Sep 9, 2025
1cd6ce6
Add tests for Set-SqlDscConfigurationOption to validate parameter set…
johlju Sep 9, 2025
c718cfd
Fix null check for operator object retrieval in Get-AgentOperatorObje…
johlju Sep 9, 2025
257ce03
Add SuppressMessage attributes to Get-SqlDscConfigurationOption and S…
johlju Sep 9, 2025
563473d
Refactor parameter declaration in Get-SqlDscConfigurationOption and S…
johlju Sep 9, 2025
5b73f88
Add -Force parameter to Add-Member for Configuration property in Set-…
johlju Sep 9, 2025
2fa4a68
Remove unused pipeline input handling for ServerObject in Get-SqlDscC…
johlju Sep 9, 2025
125fbb1
Add -Force parameter to Set-SqlDscAgentAlert in tests for improved fu…
johlju Sep 9, 2025
182ae17
Remove unused SuppressMessage attribute for empty catch block in Set-…
johlju Sep 9, 2025
9c89732
Add -Force parameter to Set-SqlDscAgentAlert calls in integration tes…
johlju Sep 9, 2025
9ce011e
Enhance Assert-SqlDscAgentOperator to support pipeline input and upda…
johlju Sep 9, 2025
6f3e823
Enable and disable Agent XPs component in integration tests for SQL S…
johlju Sep 9, 2025
10835e5
Add SuppressMessage attribute to Assert-SqlDscAgentOperator for Scrip…
johlju Sep 9, 2025
1eee5f8
Add integration tests for Get-SqlDscConfigurationOption command
johlju Sep 9, 2025
339901b
Add integration tests for Set-SqlDscConfigurationOption command
johlju Sep 9, 2025
61e6fbc
Fix environment variable handling in Set-SqlDscConfigurationOption tests
johlju Sep 9, 2025
2643c05
Add return statement after Write-Error in Set-SqlDscConfigurationOpti…
johlju Sep 9, 2025
d596651
Add -ErrorAction 'Stop' to Set-SqlDscAgentAlert calls in integration …
johlju Sep 9, 2025
27d7863
Remove redundant SuppressMessageAttribute in Set-SqlDscAgentAlert.Tes…
johlju Sep 9, 2025
72a2ae7
Rename test context for clarity when Refresh parameter is not specifi…
johlju Sep 9, 2025
a5f4221
Fix formatting of -ErrorAction parameter in Disable-SqlDscAgentOperat…
johlju Sep 9, 2025
cc955a4
Rename context for clarity when the specified configuration option do…
johlju Sep 9, 2025
e8120b8
Remove redundant test case for non-existent operator in Assert-SqlDsc…
johlju Sep 10, 2025
9026c4a
Clarify syntax rule for boolean assertions in Pester guidelines
johlju Sep 10, 2025
6efe648
Fix formatting of IsDynamic assertion in Get-SqlDscConfigurationOptio…
johlju Sep 10, 2025
966fe0f
Fix formatting of Disabled assertions in DSC_SqlLogin integration tests
johlju Sep 10, 2025
f86a631
Fix formatting of boolean assertions in DSC_SqlRS_Default integration…
johlju Sep 10, 2025
677c97c
Fix formatting of boolean assertions in DSC_SqlRS integration tests
johlju Sep 10, 2025
a17c798
Fix formatting of boolean assertions in DSC_SqlAGDatabase tests
johlju Sep 10, 2025
69ac646
Remove unnecessary blank line in DSC_SqlAGDatabase tests
johlju Sep 10, 2025
73279fc
Fix formatting of boolean assertions in DSC_SqlAlias tests
johlju Sep 10, 2025
4e954ee
Remove commented-out cleanup code in DSC_SqlLogin tests
johlju Sep 10, 2025
926e98b
Fix formatting of boolean assertions in Test-LoginEffectivePermission…
johlju Sep 10, 2025
0580bf6
Add OUTPUTS section to Set-SqlDscConfigurationOption documentation
johlju Sep 10, 2025
550faf4
Add tab completion tests for Get-SqlDscConfigurationOption and Set-Sq…
johlju Sep 10, 2025
96755fb
Remove trailing whitespace in 1-EnableDatabaseMail.ps1
johlju Sep 10, 2025
f6a8c81
Rename 'OptionValue' parameter to 'Value' in Set-SqlDscConfigurationO…
johlju Sep 10, 2025
d6d6a59
Add Test-SqlDscConfigurationOption function to validate server config…
johlju Sep 10, 2025
1989447
Add Test-SqlDscConfigurationOption integration test to pipeline
johlju Sep 10, 2025
c8a9a7c
Add tests for pipeline input handling in New-SqlDscAgentAlert
johlju Sep 10, 2025
0f8fb5e
Add unit tests for enabling SQL Agent operators with various paramete…
johlju Sep 10, 2025
3b74eb6
Add tests for creating SQL Agent operators with various properties
johlju Sep 10, 2025
f69b275
Add tests for updating SQL Agent operators with various properties
johlju Sep 10, 2025
8477aa4
Remove verbose output test for Agent XPs configuration option
johlju Sep 10, 2025
ce104cb
Refactor WeekDays enum values and update related tests for clarity
johlju Sep 10, 2025
0b7c82b
Update PagerDays property values in Set-SqlDscAgentOperator tests for…
johlju Sep 11, 2025
cf61df7
Update PagerDays property values in Set-SqlDscAgentOperator tests for…
johlju Sep 11, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ applyTo: "**/*.[Tt]ests.ps1"

## Syntax Rules
- PascalCase: `Describe`, `Context`, `It`, `Should`, `BeforeAll`, `BeforeEach`, `AfterAll`, `AfterEach`
- Prefer `-BeTrue`/`-BeFalse` over `-Be $true`/`-Be $false`
- Use `-BeTrue`/`-BeFalse` never `-Be $true`/`-Be $false`
- Never use `Assert-MockCalled`, use `Should -Invoke` instead
- No `Should -Not -Throw` - invoke commands directly
- Never add an empty `-MockWith` block
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,11 @@ applyTo: "**/*.ps?(m|d)1"
- Include a `Force` parameter for functions that uses `$PSCmdlet.ShouldContinue` or `$PSCmdlet.ShouldProcess`
- For state-changing functions, use `SupportsShouldProcess`
- Place ShouldProcess check immediately before each state-change
- Set `ConfirmImpact` to 'Low', 'Medium', or 'High' depending on risk
- `$PSCmdlet.ShouldProcess` must use required pattern
- Inside `$PSCmdlet.ShouldProcess`-block, avoid using `Write-Verbose`
- Never use backtick as line continuation in production code.
- Set `$ErrorActionPreference = 'Stop'` before commands using `-ErrorAction 'Stop'`; restore after
- Set `$ErrorActionPreference = 'Stop'` before commands using `-ErrorAction 'Stop'`; restore previous value after

## Output streams

Expand All @@ -90,8 +91,8 @@ applyTo: "**/*.ps?(m|d)1"
- Use `Write-Verbose` for: High-level execution flow only; User-actionable information
- Use `Write-Information` for: User-facing status updates; Important operational messages; Non-error state changes
- Use `Write-Warning` for: Non-fatal issues requiring attention; Deprecated functionality usage; Configuration problems that don't block execution
- Use `$PSCmdlet.ThrowTerminatingError()` for terminating errors (except for classes), use relevant error category, in try-catch include exception
- Use `Write-Error` for non-terminating errors, use relevant error category
- Use `$PSCmdlet.ThrowTerminatingError()` for terminating errors (except for classes), use relevant error category, in try-catch include exception with localized message
- Use `Write-Error` for non-terminating errors, use relevant error category; always use `return` after `Write-Error` to avoid further processing

## ShouldProcess Required Pattern

Expand Down Expand Up @@ -184,6 +185,7 @@ function Get-Something
- Assign function results to variables rather than inline calls
- Return a single, consistent object type per function
- return `$null` for no objects/non-terminating errors
- Use `::new()` static method instead of `New-Object` for .NET types, e.g `[System.Management.Automation.ErrorRecord]::new()`

### Security & Safety

Expand All @@ -207,6 +209,7 @@ function Get-Something
- End files with only one blank line
- Use CR+LF line endings
- Maximum two consecutive newlines
- No line shall have trailing whitespace

## File Encoding

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ applyTo: "tests/[u]Unit/**/*.[Tt]ests.ps1"
Use this exact setup block before `Describe`:

```powershell
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '')]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Suppressing this rule because Script Analyzer does not understand Pester syntax.')]
param ()

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.vs
output/
coverage.xml
testResults.xml
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `Set-SqlDscDatabaseDefault`
- Added new command to set default objects of a database in a SQL Server
Database Engine instance (issue [#2178](https://github.com/dsccommunity/SqlServerDsc/issues/2178)).
- `Set-SqlDscConfigurationOption`
- Added new command to set SQL Server Database Engine configuration options
using SMO with validation, ShouldProcess support, and dynamic tab completion.
- `Test-SqlDscConfigurationOption`
- Added new command to test if SQL Server Database Engine configuration options
have the specified value using SMO with dynamic tab completion for both
option names and values.
- `Get-SqlDscConfigurationOption`
- Enhanced existing command to return user-friendly metadata objects by default
with properties Name, RunValue, ConfigValue, Minimum, Maximum, and IsDynamic.
- Added `-Raw` switch to return original SMO ConfigProperty objects for
backward compatibility.
- Added dynamic tab completion for the `-Name` parameter.
- The command can set the default filegroup, default FILESTREAM filegroup,
and default Full-Text catalog using SMO methods SetDefaultFileGroup,
SetDefaultFileStreamFileGroup, and SetDefaultFullTextCatalog.
Expand Down Expand Up @@ -81,6 +94,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added `Get-SqlDscAgentAlert`, `New-SqlDscAgentAlert`,
`Set-SqlDscAgentAlert`, `Remove-SqlDscAgentAlert`, and `Test-SqlDscAgentAlert`
to manage SQL Agent alerts on a Database Engine instance.
- Added new public commands for SQL Agent Operator management:
- `Get-SqlDscAgentOperator` - Get SQL Agent Operators from a SQL Server
Database Engine instance
- `New-SqlDscAgentOperator` - Create a new SQL Agent Operator with specified properties
- `Set-SqlDscAgentOperator` - Update existing SQL Agent Operator properties
- `Remove-SqlDscAgentOperator` - Remove a SQL Agent Operator from the instance
- `Enable-SqlDscAgentOperator` - Enable a SQL Agent Operator
- `Disable-SqlDscAgentOperator` - Disable a SQL Agent Operator
- `Test-SqlDscIsAgentOperator` - Test if a SQL Agent Operator exists
- Supports pipeline input for both ServerObject and OperatorObject where applicable
- Includes comprehensive unit tests and follows ShouldProcess patterns
- Added new public commands for database management:
- `Get-SqlDscDatabase` - Get databases from a SQL Server Database Engine instance
- `New-SqlDscDatabase` - Create a new database with specified properties
Expand All @@ -91,9 +115,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
patterns
- Database objects can also be used as pipeline input for Set and Remove operations
- Commands include comprehensive validation, localization, and ShouldProcess support
- Added private function `Get-CommandParameter` to filter command parameters
by excluding specified parameter names and common parameters, providing a
reusable way to determine settable properties on objects.

### Changed

- Improved code quality by ensuring all function invocations in the private
and public functions use named parameters instead of positional parameters.
- SqlServerDsc
- Updated GitVersion.yml feature branch regex pattern to use anchor `^f(eature(s)?)?[\/-]`
for more precise branch name matching.
Expand Down
11 changes: 11 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@ stages:
'tests/Integration/Commands/Assert-SqlDscLogin.Integration.Tests.ps1'
'tests/Integration/Commands/New-SqlDscLogin.Integration.Tests.ps1'
'tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1'
'tests/Integration/Commands/Get-SqlDscConfigurationOption.Integration.Tests.ps1'
'tests/Integration/Commands/Set-SqlDscConfigurationOption.Integration.Tests.ps1'
'tests/Integration/Commands/Test-SqlDscConfigurationOption.Integration.Tests.ps1'
'tests/Integration/Commands/Disable-SqlDscLogin.Integration.Tests.ps1'
'tests/Integration/Commands/Enable-SqlDscLogin.Integration.Tests.ps1'
'tests/Integration/Commands/Test-SqlDscIsLoginEnabled.Integration.Tests.ps1'
Expand All @@ -311,8 +314,16 @@ stages:
'tests/Integration/Commands/New-SqlDscAgentAlert.Integration.Tests.ps1'
'tests/Integration/Commands/Set-SqlDscAgentAlert.Integration.Tests.ps1'
'tests/Integration/Commands/Test-SqlDscAgentAlert.Integration.Tests.ps1'
'tests/Integration/Commands/Get-SqlDscAgentOperator.Integration.Tests.ps1'
'tests/Integration/Commands/New-SqlDscAgentOperator.Integration.Tests.ps1'
'tests/Integration/Commands/Set-SqlDscAgentOperator.Integration.Tests.ps1'
'tests/Integration/Commands/Test-SqlDscIsAgentOperator.Integration.Tests.ps1'
'tests/Integration/Commands/Assert-SqlDscAgentOperator.Integration.Tests.ps1'
'tests/Integration/Commands/Enable-SqlDscAgentOperator.Integration.Tests.ps1'
'tests/Integration/Commands/Disable-SqlDscAgentOperator.Integration.Tests.ps1'
# Group 8
'tests/Integration/Commands/Remove-SqlDscAgentAlert.Integration.Tests.ps1'
'tests/Integration/Commands/Remove-SqlDscAgentOperator.Integration.Tests.ps1'
'tests/Integration/Commands/Remove-SqlDscDatabase.Integration.Tests.ps1'
'tests/Integration/Commands/Remove-SqlDscRole.Integration.Tests.ps1'
'tests/Integration/Commands/Remove-SqlDscLogin.Integration.Tests.ps1'
Expand Down
2 changes: 1 addition & 1 deletion source/Classes/020.SqlRSSetup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ class SqlRSSetup : ResourceBase
'InstallFolder'
'LogPath'
) |
Where-Object {
Where-Object -FilterScript {
$properties.ContainsKey($_)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,3 @@ Configuration Example
}
}
}

82 changes: 82 additions & 0 deletions source/Private/ConvertTo-FormattedParameterDescription.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<#
.SYNOPSIS
Converts a hashtable of bound parameters into a formatted string for ShouldProcess descriptions.

.DESCRIPTION
This function takes a hashtable of bound parameters and formats them into a readable string
for use in ShouldProcess verbose descriptions. It excludes non-settable parameters and
formats each parameter as 'ParameterName: Value'.

.PARAMETER BoundParameters
Hashtable of bound parameters (typically $PSBoundParameters).

.PARAMETER Exclude
Array of parameter names to exclude from the formatted output.

.OUTPUTS
System.String

Returns a formatted string with parameters and their values.

.EXAMPLE
$formattedText = ConvertTo-FormattedParameterDescription -BoundParameters $PSBoundParameters -Exclude @('ServerObject', 'Name', 'Force')

Returns a formatted string like:
"
EmailAddress: '[email protected]'
CategoryName: 'Notifications'
"
#>
function ConvertTo-FormattedParameterDescription
{
[CmdletBinding()]
[OutputType([System.String])]
param
(
[Parameter(Mandatory = $true)]
[System.Collections.Hashtable]
$BoundParameters,

[Parameter()]
[System.String[]]
$Exclude = @()
)

$parameterDescriptions = @()

foreach ($parameter in ($BoundParameters.Keys | Sort-Object))
{
if ($parameter -notin $Exclude)
{
$raw = $BoundParameters[$parameter]

$value = if ($raw -is [System.Security.SecureString])
{
'***'
}
elseif ($raw -is [System.Management.Automation.PSCredential])
{
$raw.UserName
}
elseif ($raw -is [System.Array])
{
($raw -join ', ')
}
else
{
$raw
}

$parameterDescriptions += "$parameter`: '$value'"
}
}

if ($parameterDescriptions.Count -gt 0)
{
return "`r`n " + ($parameterDescriptions -join "`r`n ")
}
else
{
return " $($script:localizedData.ConvertTo_FormattedParameterDescription_NoParametersToUpdate)"
}
}
77 changes: 77 additions & 0 deletions source/Private/Get-AgentOperatorObject.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<#
.SYNOPSIS
Retrieves a SQL Server Agent Operator object.

.DESCRIPTION
This private function retrieves a SQL Server Agent Operator object using the provided
parameters. If the operator is not found, it throws a non-terminating error. Callers
can use -ErrorAction to control error behavior.

.PARAMETER ServerObject
Specifies the server object on which to retrieve the operator.

.PARAMETER Name
Specifies the name of the operator to retrieve.

.PARAMETER Refresh
Specifies whether to refresh the operators collection before retrieving the operator.
When specified, the function calls Refresh() on the JobServer.Operators collection.

.INPUTS
None.

.OUTPUTS
Microsoft.SqlServer.Management.Smo.Agent.Operator

Returns the operator object if found.

.EXAMPLE
$operatorObject = Get-AgentOperatorObject -ServerObject $serverObject -Name 'TestOperator'

Returns the SQL Agent Operator object for 'TestOperator', throws error if not found.

.EXAMPLE
$operatorObject = Get-AgentOperatorObject -ServerObject $serverObject -Name 'TestOperator' -Refresh

Returns the SQL Agent Operator object for 'TestOperator' after refreshing the operators collection.
#>
function Get-AgentOperatorObject
{
[CmdletBinding()]
[OutputType([Microsoft.SqlServer.Management.Smo.Agent.Operator])]
param
(
[Parameter(Mandatory = $true)]
[Microsoft.SqlServer.Management.Smo.Server]
$ServerObject,

[Parameter(Mandatory = $true)]
[System.String]
$Name,

[Parameter()]
[System.Management.Automation.SwitchParameter]
$Refresh
)

Write-Verbose -Message ($script:localizedData.Get_AgentOperatorObject_GettingOperator -f $Name)

if ($Refresh)
{
Write-Verbose -Message $script:localizedData.Get_AgentOperatorObject_RefreshingOperators
$ServerObject.JobServer.Operators.Refresh()
}

$operatorObject = $ServerObject.JobServer.Operators[$Name]

if ($null -eq $operatorObject)
{
$errorMessage = $script:localizedData.AgentOperator_NotFound -f $Name

Write-Error -Message $errorMessage -Category 'ObjectNotFound' -ErrorId 'GAOO0001' -TargetObject $Name

return $null
}

return $operatorObject
}
55 changes: 55 additions & 0 deletions source/Private/Get-CommandParameter.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<#
.SYNOPSIS
Gets command parameters excluding specified ones.

.DESCRIPTION
This private function filters command parameters by excluding specified parameter names,
common parameters, and optional common parameters. It returns an array of parameter names
that can be used to set properties on objects.

.PARAMETER Command
Specifies the command information object containing parameter definitions.

.PARAMETER Exclude
Specifies an optional array of parameter names to exclude from the result.
Common parameters and optional common parameters are always excluded.

.INPUTS
None.

.OUTPUTS
System.String[]

Returns an array of parameter names that are not excluded.

.EXAMPLE
$settableProperties = Get-CommandParameter -Command $MyInvocation.MyCommand -Exclude @('ServerObject', 'Name', 'PassThru', 'Force')

Returns all parameters except the excluded ones and common parameters.

.EXAMPLE
$settableProperties = Get-CommandParameter -Command $MyInvocation.MyCommand

Returns all parameters except common parameters and optional common parameters.
#>
function Get-CommandParameter
{
[CmdletBinding()]
[OutputType([System.String[]])]
param
(
[Parameter(Mandatory = $true)]
[System.Management.Automation.FunctionInfo]
$Command,

[Parameter()]
[System.String[]]
$Exclude = @()
)

$parametersWithoutCommon = Remove-CommonParameter -Hashtable $Command.Parameters

$settableProperties = $parametersWithoutCommon.Keys | Where-Object -FilterScript { $_ -notin $Exclude }

return $settableProperties
}
Loading
Loading