-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- SqlServerDsc - Add new resource SqlServerAudit. - The following classes were added to the module: - `SqlResourceBase` - class that can be inherited by class-based resource and provides default DSC properties and method for get a `[Server]`-object. - The following public functions were added to the module (see comment-based help for more information): - `Invoke-SqlDscQuery` - `Get-SqlDscAudit` - `New-SqlDscAudit` - `Set-SqlDscAudit` - `Remove-SqlDscAudit` - `Enable-SqlDscAudit` - `Disable-SqlDscAudit` - `Get-DscProperty` - Added parameter `ExcludeName` to exclude property names from being returned. - SqlPermission - Fix comment-based help. - `ConvertTo-Reason` - Fix to handle `$null` values on Windows PowerShell. - If the property name contain the word 'Path' the value will be parsed to replace backslash or slashes at the end of the string, e.g. `'/mypath/'` will become `'/mypath'`. - `ResourceBase` - Now handles `Ensure` correctly from derived `GetCurrentState()`. But requires that the `GetCurrentState()` only return key property if object is present, and does not return key property if object is absent. Optionally the resource's derived `GetCurrentState()` can handle `Ensure` itself.
- Loading branch information
Showing
45 changed files
with
7,215 additions
and
110 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<# | ||
.SYNOPSIS | ||
The SqlResource base have generic properties and methods for the class-based | ||
resources. | ||
.PARAMETER InstanceName | ||
The name of the _SQL Server_ instance to be configured. Default value is | ||
`'MSSQLSERVER'`. | ||
.PARAMETER ServerName | ||
The host name of the _SQL Server_ to be configured. Default value is the | ||
current computer name. | ||
.PARAMETER Credential | ||
Specifies the credential to use to connect to the _SQL Server_ instance. | ||
If parameter **Credential'* is not provided then the resource instance is | ||
run using the credential that runs the configuration. | ||
.PARAMETER Reasons | ||
Returns the reason a property is not in desired state. | ||
#> | ||
class SqlResourceBase : ResourceBase | ||
{ | ||
<# | ||
Property for holding the server connection object. | ||
This should be an object of type [Microsoft.SqlServer.Management.Smo.Server] | ||
but using that type fails the build process currently. | ||
See issue https://github.com/dsccommunity/DscResource.DocGenerator/issues/121. | ||
#> | ||
hidden [System.Object] $SqlServerObject | ||
|
||
[DscProperty(Key)] | ||
[System.String] | ||
$InstanceName | ||
|
||
[DscProperty()] | ||
[System.String] | ||
$ServerName = (Get-ComputerName) | ||
|
||
[DscProperty()] | ||
[PSCredential] | ||
$Credential | ||
|
||
[DscProperty(NotConfigurable)] | ||
[Reason[]] | ||
$Reasons | ||
|
||
SqlResourceBase () : base () | ||
{ | ||
$this.SqlServerObject = $null | ||
} | ||
|
||
<# | ||
Returns and reuses the server connection object. If the server connection | ||
object does not exist a connection to the SQL Server instance will occur. | ||
This should return an object of type [Microsoft.SqlServer.Management.Smo.Server] | ||
but using that type fails the build process currently. | ||
See issue https://github.com/dsccommunity/DscResource.DocGenerator/issues/121. | ||
#> | ||
hidden [System.Object] GetServerObject() | ||
{ | ||
if (-not $this.SqlServerObject) | ||
{ | ||
$connectSqlDscDatabaseEngineParameters = @{ | ||
ServerName = $this.ServerName | ||
InstanceName = $this.InstanceName | ||
} | ||
|
||
if ($this.Credential) | ||
{ | ||
$connectSqlDscDatabaseEngineParameters.Credential = $this.Credential | ||
} | ||
|
||
$this.SqlServerObject = Connect-SqlDscDatabaseEngine @connectSqlDscDatabaseEngineParameters | ||
} | ||
|
||
return $this.SqlServerObject | ||
} | ||
} |
Oops, something went wrong.