<commit_before>﻿Function Get-TargetResource
{
    [CmdletBinding()]
    [OutputType([System.Collections.Hashtable])]
    param(
        [parameter(Mandatory = $true)]
        [String]
        $InstanceName,

        [parameter(Mandatory = $true)]
        [String]
        $OptionName,

        [parameter(Mandatory = $true)]
        [Int32]
        $OptionValue,

        [ValidateSet('Present', 'Absent')]
        [String]
        $Ensure = 'Present'
    )

    if(Test-TargetResource $InstanceName $OptionName $OptionValue $Ensure)
    {
        $Ensure = 'Present'
    }
    else
    {
        $Ensure = 'Absent'
    }
    
    $returnValue = @{
        InstanceName = $InstanceName
        OptionName = $OptionName
        OptionValue = $OptionValue
        Ensure = $Ensure
    }
    
    return $returnValue
}

Function Set-TargetResource
{
    [CmdletBinding()]
    [OutputType([System.Collections.Hashtable])]
    param(
        [parameter(Mandatory = $true)]
        [String]
        $InstanceName,

        [parameter(Mandatory = $true)]
        [String]
        $OptionName,

        [parameter(Mandatory = $true)]
        [Int32]
        $OptionValue,

        [ValidateSet('Present', 'Absent')]
        [String]
        $Ensure = 'Present'
    )

    $sqlServer = Get-SqlServerObject $InstanceName

    $option = $sqlServer.Configuration.Properties | where {$_.DisplayName -eq $optionName}

    if(!$option)
    {
        throw "Specified option '$OptionName' was not found!"
    }

    $option.ConfigValue = $OptionValue
    $sqlServer.Configuration.Alter()
    if ($option.IsDynamic -eq $true)
    {  
        Write-Verbose "Configuration option has been updated."
    }
    else
    {
        Write-Warning "Configuration option will be updated when SQL Server is restarted."
    }
}

Function Test-TargetResource
{
    [CmdletBinding()]
    [OutputType([Boolean])]
    param(
        [parameter(Mandatory = $true)]
        [String]
        $InstanceName,

        [parameter(Mandatory = $true)]
        [String]
        $OptionName,

        [parameter(Mandatory = $true)]
        [Int32]
        $OptionValue,

        [ValidateSet('Present', 'Absent')]
        [String]
        $Ensure = 'Present'
    )<commit_msg>xSQLServerConfiguration: Updated write-warning to write-verbose in Set-TargetResource;<commit_after>﻿Function Get-TargetResource
{
    [CmdletBinding()]
    [OutputType([System.Collections.Hashtable])]
    param(
        [parameter(Mandatory = $true)]
        [String]
        $InstanceName,

        [parameter(Mandatory = $true)]
        [String]
        $OptionName,

        [parameter(Mandatory = $true)]
        [Int32]
        $OptionValue,

        [ValidateSet('Present', 'Absent')]
        [String]
        $Ensure = 'Present'
    )

    if(Test-TargetResource $InstanceName $OptionName $OptionValue $Ensure)
    {
        $Ensure = 'Present'
    }
    else
    {
        $Ensure = 'Absent'
    }
    
    $returnValue = @{
        InstanceName = $InstanceName
        OptionName = $OptionName
        OptionValue = $OptionValue
        Ensure = $Ensure
    }
    
    return $returnValue
}

Function Set-TargetResource
{
    [CmdletBinding()]
    [OutputType([System.Collections.Hashtable])]
    param(
        [parameter(Mandatory = $true)]
        [String]
        $InstanceName,

        [parameter(Mandatory = $true)]
        [String]
        $OptionName,

        [parameter(Mandatory = $true)]
        [Int32]
        $OptionValue,

        [ValidateSet('Present', 'Absent')]
        [String]
        $Ensure = 'Present'
    )

    $sqlServer = Get-SqlServerObject $InstanceName

    $option = $sqlServer.Configuration.Properties | where {$_.DisplayName -eq $optionName}

    if(!$option)
    {
        throw "Specified option '$OptionName' was not found!"
    }

    $option.ConfigValue = $OptionValue
    $sqlServer.Configuration.Alter()
    if ($option.IsDynamic -eq $true)
    {  
        Write-Verbose "Configuration option has been updated."
    }
    else
    {
        Write-Verbose "Configuration option will be updated when SQL Server is restarted."
    }
}

Function Test-TargetResource
{
    [CmdletBinding()]
    [OutputType([Boolean])]
    param(
        [parameter(Mandatory = $true)]
        [String]
        $InstanceName,

        [parameter(Mandatory = $true)]
        [String]
        $OptionName,

        [parameter(Mandatory = $true)]
        [Int32]
        $OptionValue,

        [ValidateSet('Present', 'Absent')]
        [String]
        $Ensure = 'Present'
    )
{'fraction_non_alphanumeric': 0.12221977537987228, 'fraction_numerical': 0.0026425897379431843, 'mean_word_length': 2.1454293628808863, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2276073', 'n_tokens_mistral': 1387, 'n_tokens_neox': 1380, 'n_words': 264}