diff --git a/.MetaTestOptIn.json b/.MetaTestOptIn.json index 5ae00fae..a5f60a34 100644 --- a/.MetaTestOptIn.json +++ b/.MetaTestOptIn.json @@ -3,6 +3,11 @@ "Common Tests - Validate Example Files", "Common Tests - Validate Module Files", "Common Tests - Validate Script Files", + "Common Tests - Required Script Analyzer Rules", + "Common Tests - Flagged Script Analyzer Rules", + "Common Tests - New Error-Level Script Analyzer Rules", + "Common Tests - Custom Script Analyzer Rules", "Common Tests - Validate Example Files To Be Published", - "Common Tests - Validate Markdown Links" + "Common Tests - Validate Markdown Links", + "Common Tests - Relative Path Length" ] diff --git a/CHANGELOG.md b/CHANGELOG.md index da0dba7c..c1aef787 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ## Unreleased +- Correct PSSA custom rule violations - fixes [Issue #209](https://github.com/PowerShell/ComputerManagementDsc/issues/209). +- Correct long example filenames for PowerShellExecutionPolicy examples. +- Opted into Common Tests 'Required Script Analyzer Rules', + 'Flagged Script Analyzer Rules', 'New Error-Level Script Analyzer Rules' + 'Custom Script Analyzer Rules' and 'Relative Path Length' - + fixes [Issue #152](https://github.com/PowerShell/ComputerManagementDsc/issues/152). - PowerPlan: - Added support to specify the desired power plan either as name or guid. Fixes [Issue #59](https://github.com/PowerShell/ComputerManagementDsc/issues/59) diff --git a/Modules/ComputerManagementDsc/DSCResources/MSFT_ScheduledTask/MSFT_ScheduledTask.psm1 b/Modules/ComputerManagementDsc/DSCResources/MSFT_ScheduledTask/MSFT_ScheduledTask.psm1 index 53f9d8c3..24ece42e 100644 --- a/Modules/ComputerManagementDsc/DSCResources/MSFT_ScheduledTask/MSFT_ScheduledTask.psm1 +++ b/Modules/ComputerManagementDsc/DSCResources/MSFT_ScheduledTask/MSFT_ScheduledTask.psm1 @@ -997,7 +997,8 @@ function Set-TargetResource -ArgumentName ExecuteAsGMSA } - if($SynchronizeAcrossTimeZone -and ($ScheduleType -notin @('Once', 'Daily', 'Weekly'))) { + if ($SynchronizeAcrossTimeZone -and ($ScheduleType -notin @('Once', 'Daily', 'Weekly'))) + { New-InvalidArgumentException ` -Message ($script:localizedData.SynchronizeAcrossTimeZoneInvalidScheduleType) ` -ArgumentName SynchronizeAcrossTimeZone diff --git a/Modules/ComputerManagementDsc/DSCResources/MSFT_WindowsEventLog/MSFT_WindowsEventLog.psm1 b/Modules/ComputerManagementDsc/DSCResources/MSFT_WindowsEventLog/MSFT_WindowsEventLog.psm1 index 831075be..e5d254bc 100644 --- a/Modules/ComputerManagementDsc/DSCResources/MSFT_WindowsEventLog/MSFT_WindowsEventLog.psm1 +++ b/Modules/ComputerManagementDsc/DSCResources/MSFT_WindowsEventLog/MSFT_WindowsEventLog.psm1 @@ -114,7 +114,7 @@ function Set-TargetResource [System.String] $LogFilePath ) - + $log = Get-WindowsEventLog -LogName $LogName if ($null -eq $log) @@ -177,7 +177,6 @@ function Set-TargetResource if ($PSBoundParameters.ContainsKey('LogRetentionDays')) { - if ($LogMode -eq 'AutoBackup' -and (Get-EventLog -List | Where-Object {$_.Log -like $LogName})) { $matchingEventLog = Get-EventLog -List | Where-Object -FilterScript { @@ -262,7 +261,7 @@ function Test-TargetResource ) $log = Get-WindowsEventLog -LogName $LogName - + if ($null -eq $log) { return @@ -272,7 +271,6 @@ function Test-TargetResource if ($IsEnabled -eq $true) { - if ($PSBoundParameters.ContainsKey('IsEnabled') -and $log.IsEnabled -ne $IsEnabled) { Write-Verbose -Message ($localizedData.TestingEventlogIsEnabled -f $LogName, $IsEnabled) @@ -305,7 +303,6 @@ function Test-TargetResource if ($PSBoundParameters.ContainsKey('LogRetentionDays')) { - if ($LogMode -eq 'AutoBackup') { $minimumRetentionDays = Get-EventLog -List | Where-Object -FilterScript { $_.Log -eq $LogName } diff --git a/Modules/ComputerManagementDsc/Examples/Resources/PowerShellExecutionPolicy/1-PowerShellExecutionPolicy_SetPowerShellExecutionPolicy_Config.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/PowerShellExecutionPolicy/1-PowerShellExecutionPolicy_SetPolicy_Config.ps1 similarity index 93% rename from Modules/ComputerManagementDsc/Examples/Resources/PowerShellExecutionPolicy/1-PowerShellExecutionPolicy_SetPowerShellExecutionPolicy_Config.ps1 rename to Modules/ComputerManagementDsc/Examples/Resources/PowerShellExecutionPolicy/1-PowerShellExecutionPolicy_SetPolicy_Config.ps1 index ca1f105a..316f5253 100644 --- a/Modules/ComputerManagementDsc/Examples/Resources/PowerShellExecutionPolicy/1-PowerShellExecutionPolicy_SetPowerShellExecutionPolicy_Config.ps1 +++ b/Modules/ComputerManagementDsc/Examples/Resources/PowerShellExecutionPolicy/1-PowerShellExecutionPolicy_SetPolicy_Config.ps1 @@ -21,7 +21,7 @@ .DESCRIPTION This example shows how to configure powershell's execution policy for the specified execution policy scope. #> -Configuration PowerShellExecutionPolicy_SetPowerShellExecutionPolicy_Config +Configuration PowerShellExecutionPolicy_SetPolicy_Config { Import-DscResource -ModuleName ComputerManagementDsc diff --git a/Modules/ComputerManagementDsc/Examples/Resources/PowerShellExecutionPolicy/2-PowerShellExecutionPolicy_SetPowershellExecutionPolicyForMultipleScopes_Config.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/PowerShellExecutionPolicy/2-PowerShellExecutionPolicy_SetPolicyForMultipleScopes_Config.ps1 similarity index 93% rename from Modules/ComputerManagementDsc/Examples/Resources/PowerShellExecutionPolicy/2-PowerShellExecutionPolicy_SetPowershellExecutionPolicyForMultipleScopes_Config.ps1 rename to Modules/ComputerManagementDsc/Examples/Resources/PowerShellExecutionPolicy/2-PowerShellExecutionPolicy_SetPolicyForMultipleScopes_Config.ps1 index ec45ea88..c9f0bc58 100644 --- a/Modules/ComputerManagementDsc/Examples/Resources/PowerShellExecutionPolicy/2-PowerShellExecutionPolicy_SetPowershellExecutionPolicyForMultipleScopes_Config.ps1 +++ b/Modules/ComputerManagementDsc/Examples/Resources/PowerShellExecutionPolicy/2-PowerShellExecutionPolicy_SetPolicyForMultipleScopes_Config.ps1 @@ -21,7 +21,7 @@ .DESCRIPTION This example shows how to configure multiple powershell's execution policy for a specified execution policy scope. #> -Configuration PowerShellExecutionPolicy_SetPowershellExecutionPolicyForMultipleScopes_Config +Configuration PowerShellExecutionPolicy_SetPolicyForMultipleScopes_Config { Import-DscResource -ModuleName ComputerManagementDsc