diff --git a/developing/settingupfor2022.ps1 b/developing/settingupfor2022.ps1 index 3bb4a96f..2ab799be 100644 --- a/developing/settingupfor2022.ps1 +++ b/developing/settingupfor2022.ps1 @@ -19,7 +19,7 @@ Get-DbaLogin -SqlInstance $sql1,$sql2,$sql3 | ft Get-DbaDatabase -SqlInstance $sql1,$sql2,$sql3 | ft Get-DbaAgentJob -SqlInstance $sql1,$sql2,$sql3 | ft Get-DbaDbCertificate -SqlInstance $sql1,$sql2,$sql3 | ft - + docker run -p 52000:1433 -v sqlserver:/var/opt/sqlserver -d dbatools/sqlinstance --name mssql1 docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=dbatools.IO" -p 52002:1433 --name mssql3 --hostname mssql3 -v sqlserver:/var/opt/sqlserver -d mcr.microsoft.com/mssql/server:2022-latest diff --git a/source/checks/Agent.Tests.ps1 b/source/checks/Agent.Tests.ps1 index 4762977d..f4a35283 100644 --- a/source/checks/Agent.Tests.ps1 +++ b/source/checks/Agent.Tests.ps1 @@ -1,5 +1,5 @@ $filename = $MyInvocation.MyCommand.Name.Replace('.Tests.ps1', '') -. $PSScriptRoot/../internal/assertions/Agent.Assertions.ps1 +. (Convert-Path -Path $PSScriptRoot/../internal/assertions/Agent.Assertions.ps1) [string[]]$NotContactable = (Get-PSFConfig -Module dbachecks -Name global.notcontactable).Value Set-PSFConfig -Module dbachecks -Name global.notcontactable -Value $NotContactable diff --git a/source/checks/Database.Tests.ps1 b/source/checks/Database.Tests.ps1 index d0ba8c9e..b3c1a201 100644 --- a/source/checks/Database.Tests.ps1 +++ b/source/checks/Database.Tests.ps1 @@ -1,5 +1,5 @@ $filename = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "") -. $PSScriptRoot/../internal/assertions/Database.Assertions.ps1 +. (Convert-Path -Path $PSScriptRoot/../internal/assertions/Database.Assertions.ps1) [array]$ExcludedDatabases = Get-DbcConfigValue command.invokedbccheck.excludedatabases diff --git a/source/checks/Instance.Tests.ps1 b/source/checks/Instance.Tests.ps1 index cc801ecc..77758233 100644 --- a/source/checks/Instance.Tests.ps1 +++ b/source/checks/Instance.Tests.ps1 @@ -1,5 +1,5 @@ $filename = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "") -. $PSScriptRoot/../internal/assertions/Instance.Assertions.ps1 +. (Convert-Path -Path $PSScriptRoot/../internal/assertions/Instance.Assertions.ps1) # Check out the comments at the top of Instance.Assertions for guidance on adding checks diff --git a/source/checks/Server.Tests.ps1 b/source/checks/Server.Tests.ps1 index 2c84d89b..55079253 100644 --- a/source/checks/Server.Tests.ps1 +++ b/source/checks/Server.Tests.ps1 @@ -1,12 +1,12 @@ $filename = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "") -. $PSScriptRoot/../internal/assertions/Server.Assertions.ps1 +. (Convert-Path -Path $PSScriptRoot/../internal/assertions/Server.Assertions.ps1) # follow the guidance in Instance.Assertions to add new checks $Tags = Get-CheckInformation -Check $Check -Group Server -AllChecks $AllChecks -ExcludeCheck $ChecksToExclude -if($IsLinux){ -Write-PSFMessage "We cannot run any of the Server tests from linux at the moment" -Level Warning -Return +if ($IsLinux) { + Write-PSFMessage "We cannot run any of the Server tests from linux at the moment" -Level Warning + Return } @(Get-ComputerName).ForEach{ $AllServerInfo = Get-AllServerInfo -ComputerName $Psitem -Tags $Tags @@ -44,10 +44,10 @@ Return $pingcount = Get-DbcConfigValue policy.connection.pingcount $skipping = Get-DbcConfigValue skip.connection.ping Context "Testing Ping to $psitem" { - It -skip:$skipping "Should have pinged $pingcount times for $psitem" { + It -Skip:$skipping "Should have pinged $pingcount times for $psitem" { Assert-Ping -AllServerInfo $AllServerInfo -Type Ping } - It -skip:$skipping "Average response time (ms) should Be less than $pingmsmax (ms) for $psitem" { + It -Skip:$skipping "Average response time (ms) should Be less than $pingmsmax (ms) for $psitem" { Assert-Ping -AllServerInfo $AllServerInfo -Type Average } } @@ -63,22 +63,20 @@ Return } Describe "Disk Allocation Unit" -Tags DiskAllocationUnit, Medium, $filename { - if($IsCoreCLR){ + if ($IsCoreCLR) { Context "Testing disk allocation unit on $psitem" { It "Can't run this check on Core on $psitem" -Skip { $true | Should -BeTrue } } - } - else { + } else { Context "Testing disk allocation unit on $psitem" { $computerName = $psitem $excludedisks = Get-DbcConfigValue policy.server.excludeDiskAllocationUnit - @($AllServerInfo.DiskAllocation).Where{$psitem.IsSqlDisk -eq $true}.ForEach{ - if($Psitem.Name -in $excludedisks){ + @($AllServerInfo.DiskAllocation).Where{ $psitem.IsSqlDisk -eq $true }.ForEach{ + if ($Psitem.Name -in $excludedisks) { $exclude = $true - } - else { + } else { $exclude = $false } It "$($Psitem.Name) Should be set to 64kb on $computerName" -Skip:$exclude { @@ -92,7 +90,7 @@ Return Describe "Non Standard Port" -Tags NonStandardPort, Medium, CIS, $filename { $skip = Get-DbcConfigValue skip.security.nonstandardport Context "Checking SQL Server ports on $psitem" { - It "No SQL Server Instances should be configured with port 1433 on $psitem" -skip:$skip { + It "No SQL Server Instances should be configured with port 1433 on $psitem" -Skip:$skip { Assert-NonStandardPort -AllServerInfo $AllServerInfo } } @@ -101,7 +99,7 @@ Return Describe "Server Protocols" -Tags ServerProtocol, Medium, CIS, $filename { $skip = Get-DbcConfigValue skip.security.serverprotocol Context "Checking SQL Server protocols on $psitem" { - It "All SQL Server Instances should be configured to run only TCP/IP protocol on $psitem" -skip:$skip { + It "All SQL Server Instances should be configured to run only TCP/IP protocol on $psitem" -Skip:$skip { Assert-ServerProtocol -AllServerInfo $AllServerInfo } } diff --git a/source/dbachecks.psm1 b/source/dbachecks.psm1 index 3c024518..c939ec6f 100644 --- a/source/dbachecks.psm1 +++ b/source/dbachecks.psm1 @@ -12,8 +12,7 @@ function Import-ModuleFile { else { try { $ExecutionContext.InvokeCommand.InvokeScript($false, ([scriptblock]::Create([io.file]::ReadAllText($Path))), $null, $null) - } - catch { + } catch { Write-Warning "Failed to import $Path" } } @@ -26,31 +25,20 @@ if ((Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WindowsPowerShell\dbacheck if ((Get-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\WindowsPowerShell\dbachecks\System" -Name "DoDotSource" -ErrorAction Ignore).DoDotSource) { $script:doDotSource = $true } # Execute Preimport actions -if($IsLinux){ - Write-Verbose "Loading preimport in linux" - . Import-ModuleFile -Path "$ModuleRoot/internal/scripts/preimport.ps1" -}else{ - . Import-ModuleFile -Path "$ModuleRoot\internal\scripts\preimport.ps1" -} - +. Import-ModuleFile -Path (Convert-Path -Path "$ModuleRoot\internal\scripts\preimport.ps1") # Import all internal functions -foreach ($function in (Get-ChildItem "$ModuleRoot\internal\functions\*.ps1")) { +foreach ($function in (Get-ChildItem (Convert-Path -Path "$ModuleRoot\internal\functions\*.ps1"))) { . Import-ModuleFile -Path $function.FullName } # Import all public functions -foreach ($function in (Get-ChildItem "$ModuleRoot\functions\*.ps1")) { +foreach ($function in (Get-ChildItem (Convert-Path -Path "$ModuleRoot\functions\*.ps1"))) { . Import-ModuleFile -Path $function.FullName } # Execute Postimport actions -if($IsLinux){ - Write-Verbose "Loading postimport in linux" - . Import-ModuleFile -Path "$ModuleRoot/internal/scripts/postimport.ps1" -}else{ - . Import-ModuleFile -Path "$ModuleRoot\internal\scripts\postimport.ps1" -} +. Import-ModuleFile -Path (Convert-Path -Path "$ModuleRoot\internal\scripts\postimport.ps1") if (-not (Test-Path Alias:Update-Dbachecks)) { Set-Alias -Scope Global -Name 'Update-Dbachecks' -Value 'Update-DbcRequiredModules' } $VerbosePreference = "SilentlyContinue" diff --git a/source/functions/Reset-DbcConfig.ps1 b/source/functions/Reset-DbcConfig.ps1 index b6df980a..94f70cb7 100644 --- a/source/functions/Reset-DbcConfig.ps1 +++ b/source/functions/Reset-DbcConfig.ps1 @@ -1,4 +1,4 @@ -. $script:ModuleRoot/internal/functions/Invoke-ConfigurationScript.ps1 +. (Convert-Path -Path $script:ModuleRoot/internal/functions/Invoke-ConfigurationScript.ps1) <# .SYNOPSIS Resets configuration entries to their default values. @@ -36,12 +36,10 @@ function Reset-DbcConfig { if (!$Name) { # no name provided, get all known dbachecks settings $resolvedName = (Get-DbcConfig).Name - } - elseif ($Name -match '\*') { + } elseif ($Name -match '\*') { # wildcard is used, get only the matching settings $resolvedName = (Get-DbcConfig).Name | Where-Object { $psitem -like $Name } - } - else { + } else { $resolvedName = $Name } @@ -49,8 +47,7 @@ function Reset-DbcConfig { $localName = $psitem.ToLower() if (-not (Get-DbcConfig -Name $localName)) { Stop-PSFFunction -FunctionName Reset-DbcConfig -Message "Setting named $localName does not exist. Use Get-DbcCheck to get the list of supported settings." - } - else { + } else { Write-PSFMessage -FunctionName Reset-DbcConfig -Message "resetting $localName" Unregister-PSFConfig -Module dbachecks -Name $localName [PSFramework.Configuration.ConfigurationHost]::Configurations.Remove("dbachecks.$localName") | Out-Null diff --git a/source/internal/configurations/configuration.ps1 b/source/internal/configurations/configuration.ps1 index 2af77615..5c47bc07 100644 --- a/source/internal/configurations/configuration.ps1 +++ b/source/internal/configurations/configuration.ps1 @@ -3,16 +3,17 @@ #Add some validation for values with limited options [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidAssignmentToAutomaticVariable', 'input')] -$LogFileComparisonValidationssb = { param ([string]$input) if ($input -in ('average', 'maximum')) { [PsCustomObject]@{Success = $true; value = $input} } else { [PsCustomObject]@{Success = $false; message = "must be average or maximum - $input"} +$LogFileComparisonValidationssb = { param ([string]$input) if ($input -in ('average', 'maximum')) { [PsCustomObject]@{Success = $true; value = $input } } else { + [PsCustomObject]@{Success = $false; message = "must be average or maximum - $input" } } } Register-PSFConfigValidation -Name validation.LogFileComparisonValidations -ScriptBlock $LogFileComparisonValidationssb $EmailValidationSb = { param ([string]$input) $EmailRegEx = "^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$" if (($input -match $EmailRegEx) -or -not ($input) ) { - [PsCustomObject]@{Success = $true; value = $input} + [PsCustomObject]@{Success = $true; value = $input } } else { - [PsCustomObject]@{Success = $false; message = "does not appear to be an email address - $input"} + [PsCustomObject]@{Success = $false; message = "does not appear to be an email address - $input" } } } Register-PSFConfigValidation -Name validation.EmailValidation -ScriptBlock $EmailValidationSb @@ -20,19 +21,16 @@ Register-PSFConfigValidation -Name validation.EmailValidation -ScriptBlock $Emai # some configs to help with autocompletes and other module level stuff #apps -$defaultRepo = "$script:ModuleRoot\checks" +$defaultRepo = (Convert-Path -Path "$script:ModuleRoot\checks") Set-PSFConfig -Module dbachecks -Name app.checkrepos -Value @($defaultRepo) -Initialize -Description "Where Pester tests/checks are stored" Set-PSFConfig -Module dbachecks -Name app.sqlinstance -Value $null -Initialize -Description "List of SQL Server instances that SQL-based tests will run against" Set-PSFConfig -Module dbachecks -Name app.computername -Value $null -Initialize -Description "List of Windows Servers that Windows-based tests will run against" Set-PSFConfig -Module dbachecks -Name app.sqlcredential -Value $null -Initialize -Description "The universal SQL credential if Trusted/Windows Authentication is not used" Set-PSFConfig -Module dbachecks -Name app.wincredential -Value $null -Initialize -Description "The universal Windows if default Windows Authentication is not used" -if($IsLinux){ - Set-PSFConfig -Module dbachecks -Name app.localapp -Value "$home\dbachecks" -Initialize -Description "Persisted files live here" - Set-PSFConfig -Module dbachecks -Name app.maildirectory -Value "$home\dbachecks\dbachecks.mail" -Initialize -Description "Files for mail are stored here" -}else{ - Set-PSFConfig -Module dbachecks -Name app.localapp -Value "$env:localappdata\dbachecks" -Initialize -Description "Persisted files live here" - Set-PSFConfig -Module dbachecks -Name app.maildirectory -Value "$env:localappdata\dbachecks\dbachecks.mail" -Initialize -Description "Files for mail are stored here" -} + +Set-PSFConfig -Module dbachecks -Name app.localapp -Value (Convert-Path -Path "$env:localappdata\dbachecks") -Initialize -Description "Persisted files live here" +Set-PSFConfig -Module dbachecks -Name app.maildirectory -Value (Convert-Path -Path "$env:localappdata\dbachecks\dbachecks.mail") -Initialize -Description "Files for mail are stored here" + Set-PSFConfig -Module dbachecks -Name app.cluster -Value $null -Initialize -Description "One host name for each cluster for the HADR checks" # Policy Configs @@ -52,7 +50,7 @@ Set-PSFConfig -Module dbachecks -Name policy.backup.logdir -Value $null -Initial Set-PSFConfig -Module dbachecks -Name policy.backup.fullmaxdays -Value 7 -Initialize -Description "Maximum number of days before Full Backups are considered outdated" Set-PSFConfig -Module dbachecks -Name policy.backup.diffmaxhours -Value 25 -Initialize -Description "Maximum number of hours before Diff Backups are considered outdated" Set-PSFConfig -Module dbachecks -Name policy.backup.logmaxminutes -Value 15 -Initialize -Description "Maximum number of minutes before Log Backups are considered outdated" -Set-PsFConfig -Module dbachecks -Name policy.backup.newdbgraceperiod -Value 0 -Initialize -Description "The number of hours a newly created database is allowed to not have backups" +Set-PSFConfig -Module dbachecks -Name policy.backup.newdbgraceperiod -Value 0 -Initialize -Description "The number of hours a newly created database is allowed to not have backups" Set-PSFConfig -Module dbachecks -Name policy.backup.defaultbackupcompression -Validation bool -Value $true -Initialize -Description "Default Backup Compression should be enabled `$true or disabled `$false" Set-PSFConfig -Module dbachecks -Name policy.security.clrenabled -Validation bool -Value $false -Initialize -Description "CLR Enabled should be enabled `$true or disabled `$false" Set-PSFConfig -Module dbachecks -Name policy.security.crossdbownershipchaining -Validation bool -Value $false -Initialize -Description "Cross Database Ownership Chaining should be disabled `$false" @@ -72,8 +70,8 @@ Set-PSFConfig -Module dbachecks -Name policy.diskspace.percentfree -Value 20 -In Set-PSFConfig -Module dbachecks -Name policy.dbcc.maxdays -Value 7 -Initialize -Description "Maximum number of days before DBCC CHECKDB is considered outdated" #Encryption -Set-PSFConfig -Module dbachecks -Name policy.certificateexpiration.excludedb -Value @('master', 'msdb', 'model', 'tempdb') -Initialize -Description "Databases to exclude from expired certificate checks" -Set-PSFConfig -Module dbachecks -Name policy.certificateexpiration.warningwindow -Value 1 -Initialize -Description "The number of months prior to a certificate being expired that you want warning about" +Set-PSFConfig -Module dbachecks -Name policy.certificateexpiration.excludedb -Value @('master', 'msdb', 'model', 'tempdb') -Initialize -Description "Databases to exclude from expired certificate checks" +Set-PSFConfig -Module dbachecks -Name policy.certificateexpiration.warningwindow -Value 1 -Initialize -Description "The number of months prior to a certificate being expired that you want warning about" #Identity Set-PSFConfig -Module dbachecks -Name policy.identity.usagepercent -Value 90 -Initialize -Description "Maximum percentage of max of identity column" @@ -91,9 +89,9 @@ Set-PSFConfig -Module dbachecks -Name policy.adlogingroup.excludecheck -Value "" #DBOwners Set-PSFConfig -Module dbachecks -Name policy.validdbowner.name -Value "sa" -Initialize -Description "The database owner account should be this user" -Set-PSFConfig -Module dbachecks -Name policy.validdbowner.excludedb -Value @('master', 'msdb', 'model', 'tempdb') -Initialize -Description "Databases to exclude from valid dbowner checks" +Set-PSFConfig -Module dbachecks -Name policy.validdbowner.excludedb -Value @('master', 'msdb', 'model', 'tempdb') -Initialize -Description "Databases to exclude from valid dbowner checks" Set-PSFConfig -Module dbachecks -Name policy.invaliddbowner.name -Value "sa" -Initialize -Description "The database owner account should not be this user" -Set-PSFConfig -Module dbachecks -Name policy.invaliddbowner.excludedb -Value @('master', 'msdb', 'model', 'tempdb') -Initialize -Description "Databases to exclude from invalid dbowner checks" +Set-PSFConfig -Module dbachecks -Name policy.invaliddbowner.excludedb -Value @('master', 'msdb', 'model', 'tempdb') -Initialize -Description "Databases to exclude from invalid dbowner checks" #Error Log Set-PSFConfig -Module dbachecks -Name policy.errorlog.warningwindow -Value 2 -Initialize -Description "The number of days prior to check for error log issues" @@ -122,7 +120,7 @@ Set-PSFConfig -Module dbachecks -Name policy.hadr.failureconditionlevel -Value 3 Set-PSFConfig -Module dbachecks -Name policy.hadr.healthchecktimeout -Value 30000 -Initialize -Description "Availability Group healthcheck timeout for the HADR cluster check" Set-PSFConfig -Module dbachecks -Name policy.hadr.leasetimeout -Value 20000 -Initialize -Description "Availability Group Lease timeout for the HADR cluster check" Set-PSFConfig -Module dbachecks -Name policy.hadr.sessiontimeout -Value 10 -Initialize -Description "Availability Group Replica Session timeout for the HADR replica check" -Set-PSFConfig -Module dbachecks -Name policy.cluster.NetworkProtocolsIPV4 -Value @('Internet Protocol Version 4 (TCP/IPv4)','Client for Microsoft Networks','File and Printer Sharing for Microsoft Networks') -Initialize -Description "Minimum Private Cluster Network protocols for the HADR Cluster check" +Set-PSFConfig -Module dbachecks -Name policy.cluster.NetworkProtocolsIPV4 -Value @('Internet Protocol Version 4 (TCP/IPv4)', 'Client for Microsoft Networks', 'File and Printer Sharing for Microsoft Networks') -Initialize -Description "Minimum Private Cluster Network protocols for the HADR Cluster check" Set-PSFConfig -Module dbachecks -Name policy.cluster.hostrecordttl -Value 1200 -Initialize -Description "Cluster Network Resource - HostRecordTTL for the HADR Cluster check" Set-PSFConfig -Module dbachecks -Name policy.cluster.registerallprovidersIP -Value 0 -Initialize -Description "Cluster Network Resource - RegisterAllProvidersIP for the HADR Cluster check" @@ -145,8 +143,8 @@ Set-PSFConfig -Module dbachecks -Name policy.database.autocreatestatistics -Vali Set-PSFConfig -Module dbachecks -Name policy.database.autoupdatestatistics -Validation bool -Value $true -Initialize -Description "Auto Update Statistics should be enabled `$true or disabled `$false" Set-PSFConfig -Module dbachecks -Name policy.database.autoupdatestatisticsasynchronously -Validation bool -Value $false -Initialize -Description "Auto Update Statistics Asynchronously should be enabled `$true or disabled `$false" Set-PSFConfig -Module dbachecks -Name policy.database.filegrowthexcludedb -Value @() -Initialize -Description "Databases to exclude from the file growth check" -Set-PSFConfig -Module dbachecks -Name policy.database.filegrowthtype -Value "kb" -Initialize -Description "Growth Type should be 'kb' or 'percent'" -Set-PSFConfig -Module dbachecks -Name policy.database.filegrowthvalue -Value 65535 -Initialize -Description "The auto growth value (in kb) should be equal or higher than this value. Example: A value of 65535 means at least 64MB. " +Set-PSFConfig -Module dbachecks -Name policy.database.filegrowthtype -Value "kb" -Initialize -Description "Growth Type should be 'kb' or 'percent'" +Set-PSFConfig -Module dbachecks -Name policy.database.filegrowthvalue -Value 65535 -Initialize -Description "The auto growth value (in kb) should be equal or higher than this value. Example: A value of 65535 means at least 64MB. " Set-PSFConfig -Module dbachecks -Name policy.database.logfilecount -Value 1 -Initialize -Description "The number of Log files expected on a database" Set-PSFConfig -Module dbachecks -Name policy.database.logfilesizepercentage -Value 100 -Initialize -Description "Maximum percentage of Data file Size that logfile is allowed to be." Set-PSFConfig -Module dbachecks -Name policy.database.logfilesizecomparison -Validation validation.logfilecomparisonvalidations -Value 'average' -Initialize -Description "How to compare data and log file size, options are maximum or average" @@ -162,54 +160,54 @@ Set-PSFConfig -Module dbachecks -Name database.querystoreenabled.excludedb -Valu Set-PSFConfig -Module dbachecks -Name database.querystoredisabled.excludedb -Value @() -Initialize -Description "A List of databases that we do not want to check for Query Store disabled" Set-PSFConfig -Module dbachecks -Name policy.database.filegrowthdaystocheck -Value $null -Initialize -Description "The number of days to go back to check for growth events" Set-PSFConfig -Module dbachecks -Name policy.database.trustworthyexcludedb -Value @('msdb') -Initialize -Description "A List of databases that we do not want to check for Trustworthy being on" -Set-PSFConfig -Module dbachecks -Name policy.database.duplicateindexexcludedb -Value @('msdb','ReportServer','ReportServerTempDB') -Initialize -Description "A List of databases we do not want to check for Duplicate Indexes" +Set-PSFConfig -Module dbachecks -Name policy.database.duplicateindexexcludedb -Value @('msdb', 'ReportServer', 'ReportServerTempDB') -Initialize -Description "A List of databases we do not want to check for Duplicate Indexes" Set-PSFConfig -Module dbachecks -Name policy.database.clrassembliessafeexcludedb -Value @() -Initialize -Description " A List of database what we do not want to check for SAFE CLR Assemblies" Set-PSFConfig -Module dbachecks -Name policy.database.logfilepercentused -Value 75 -Initialize -Description " The % log used we should stay below" # Policy for Ola Hallengren Maintenance Solution -Set-PSFConfig -Module dbachecks -name policy.ola.installed -Validation bool -Value $true -Initialize -Description "Checks to see if Ola Hallengren solution is installed" +Set-PSFConfig -Module dbachecks -Name policy.ola.installed -Validation bool -Value $true -Initialize -Description "Checks to see if Ola Hallengren solution is installed" Set-PSFConfig -Module dbachecks -Name policy.ola.database -Validation string -Value 'master' -Initialize -Description "The database where Ola's maintenance solution is installed" -Set-PSFConfig -Module dbachecks -name policy.ola.systemfullenabled -Validation bool -Value $true -Initialize -Description "Ola's Full System Database Backup should be enabled `$true or disabled `$false" -Set-PSFConfig -Module dbachecks -name policy.ola.userfullenabled -Validation bool -Value $true -Initialize -Description "Ola's Full User Database Backup should be enabled `$true or disabled `$false" -Set-PSFConfig -Module dbachecks -name policy.ola.userdiffenabled -Validation bool -Value $true -Initialize -Description "Ola's Diff User Database Backup should be enabled `$true or disabled `$false" -Set-PSFConfig -Module dbachecks -name policy.ola.userlogenabled -Validation bool -Value $true -Initialize -Description "Ola's Log User Database Backup should be enabled `$true or disabled `$false" -Set-PSFConfig -Module dbachecks -name policy.ola.systemfullscheduled -Validation bool -Value $true -Initialize -Description "Ola's Full System Database Backup should be scheduled `$true or disabled `$false" -Set-PSFConfig -Module dbachecks -name policy.ola.userfullscheduled -Validation bool -Value $true -Initialize -Description "Ola's Full User Database Backup should be scheduled `$true or disabled `$false" -Set-PSFConfig -Module dbachecks -name policy.ola.userdiffscheduled -Validation bool -Value $true -Initialize -Description "Ola's Diff User Database Backup should be scheduled `$true or disabled `$false" -Set-PSFConfig -Module dbachecks -name policy.ola.userlogscheduled -Validation bool -Value $true -Initialize -Description "Ola's Log User Database Backup should be scheduled `$true or disabled `$false" -Set-PSFConfig -Module dbachecks -name policy.ola.systemfullretention -Value 192 -Initialize -Description "Ola's Full System Database Backup retention number of hours" -Set-PSFConfig -Module dbachecks -name policy.ola.userfullretention -Value 192 -Initialize -Description "Ola's Full User Database Backup retention number of hours" -Set-PSFConfig -Module dbachecks -name policy.ola.userdiffretention -Value 192 -Initialize -Description "Ola's Diff User Database Backup retention number of hours" -Set-PSFConfig -Module dbachecks -name policy.ola.userlogretention -Value 192 -Initialize -Description "Ola's Log User Database Backup retention number of hours" -Set-PSFConfig -Module dbachecks -name policy.ola.CommandLogenabled -Validation bool -Value $true -Initialize -Description "Ola's CommandLog Cleanup should be enabled `$true or disabled `$false" -Set-PSFConfig -Module dbachecks -name policy.ola.CommandLogscheduled -Validation bool -Value $true -Initialize -Description "Ola's CommandLog Cleanup should be scheduled `$true or disabled `$false" -Set-PSFConfig -Module dbachecks -name policy.ola.CommandLogCleanUp -Value 30 -Initialize -Description "Ola's CommandLog Cleanup setting should be this many days" -Set-PSFConfig -Module dbachecks -name policy.ola.SystemIntegrityCheckenabled -Validation bool -Value $true -Initialize -Description "Ola's System Database Integrity should be enabled `$true or disabled `$false" -Set-PSFConfig -Module dbachecks -name policy.ola.SystemIntegrityCheckscheduled -Validation bool -Value $true -Initialize -Description "Ola's System Database Integrity should be scheduled `$true or disabled `$false" -Set-PSFConfig -Module dbachecks -name policy.ola.UserIntegrityCheckenabled -Validation bool -Value $true -Initialize -Description "Ola's User Database Integrity should be enabled `$true or disabled `$false" -Set-PSFConfig -Module dbachecks -name policy.ola.UserIntegrityCheckscheduled -Validation bool -Value $true -Initialize -Description "Ola's User Database Integrity should be scheduled `$true or disabled `$false" -Set-PSFConfig -Module dbachecks -name policy.ola.UserIndexOptimizeenabled -Validation bool -Value $true -Initialize -Description "Ola's User Index Optimization should be enabled `$true or disabled `$false" -Set-PSFConfig -Module dbachecks -name policy.ola.UserIndexOptimizescheduled -Validation bool -Value $true -Initialize -Description "Ola's User Index Optimization should be scheduled `$true or disabled `$false" -Set-PSFConfig -Module dbachecks -name policy.ola.OutputFileCleanupenabled -Validation bool -Value $true -Initialize -Description "Ola's Output File Cleanup should be enabled `$true or disabled `$false" -Set-PSFConfig -Module dbachecks -name policy.ola.OutputFileCleanupscheduled -Validation bool -Value $true -Initialize -Description "Ola's Output File Cleanup should be scheduled `$true or disabled `$false" -Set-PSFConfig -Module dbachecks -name policy.ola.OutputFileCleanUp -Value 30 -Initialize -Description "Ola's OutputFile Cleanup setting should be this many days" -Set-PSFConfig -Module dbachecks -name policy.ola.DeleteBackupHistoryenabled -Validation bool -Value $true -Initialize -Description "Ola's Delete Backup History should be enabled `$true or disabled `$false" -Set-PSFConfig -Module dbachecks -name policy.ola.DeleteBackupHistoryscheduled -Validation bool -Value $true -Initialize -Description "Ola's Delete Backup History should be scheduled `$true or disabled `$false" -Set-PSFConfig -Module dbachecks -name policy.ola.DeleteBackupHistoryCleanUp -Value 30 -Initialize -Description "Ola's Delete Backup History Cleanup setting should be this many days" -Set-PSFConfig -Module dbachecks -name policy.ola.PurgeJobHistoryenabled -Validation bool -Value $true -Initialize -Description "Ola's Purge Job History should be enabled `$true or disabled `$false" -Set-PSFConfig -Module dbachecks -name policy.ola.PurgeJobHistoryscheduled -Validation bool -Value $true -Initialize -Description "Ola's Purge Job History should be scheduled `$true or disabled `$false" -Set-PSFConfig -Module dbachecks -name policy.ola.PurgeJobHistoryCleanUp -Value 30 -Initialize -Description "Ola's Purge Backup History Cleanup setting should be this many days" -Set-PSFConfig -Module dbachecks -name ola.JobName.SystemFull -Value 'DatabaseBackup - SYSTEM_DATABASES - FULL' -Initialize -Description "The name for the Ola System Full Job" -Set-PSFConfig -Module dbachecks -name ola.JobName.UserFull -Value 'DatabaseBackup - USER_DATABASES - FULL' -Initialize -Description "The name for the Ola User Full Job" -Set-PSFConfig -Module dbachecks -name ola.JobName.UserDiff -Value 'DatabaseBackup - USER_DATABASES - DIFF' -Initialize -Description "The name for the Ola User Diff Job" -Set-PSFConfig -Module dbachecks -name ola.JobName.UserLog -Value 'DatabaseBackup - USER_DATABASES - Log' -Initialize -Description "The name for the Ola User Log Job" -Set-PSFConfig -Module dbachecks -name ola.JobName.CommandLogCleanup -Value 'CommandLog Cleanup' -Initialize -Description "The name for the Ola CommandLog Cleanup Job" -Set-PSFConfig -Module dbachecks -name ola.JobName.SystemIntegrity -Value 'DatabaseIntegrityCheck - SYSTEM_DATABASES' -Initialize -Description "The name for the Ola System Integrity Job" -Set-PSFConfig -Module dbachecks -name ola.JobName.UserIntegrity -Value 'DatabaseIntegrityCheck - USER_DATABASES' -Initialize -Description "The name for the Ola User Integrity Job" -Set-PSFConfig -Module dbachecks -name ola.JobName.UserIndex -Value 'IndexOptimize - USER_DATABASES' -Initialize -Description "The name for the Ola User Index Job" -Set-PSFConfig -Module dbachecks -name ola.JobName.OutputFileCleanup -Value 'Output File Cleanup' -Initialize -Description "The name for the Ola Output File Cleanup Job" -Set-PSFConfig -Module dbachecks -name ola.JobName.DeleteBackupHistory -Value 'sp_delete_backuphistory' -Initialize -Description "The name for the Ola Delete Backup History Job" -Set-PSFConfig -Module dbachecks -name ola.JobName.PurgeBackupHistory -Value 'sp_purge_jobhistory' -Initialize -Description "The name for the Ola Delete Purge History Job" +Set-PSFConfig -Module dbachecks -Name policy.ola.systemfullenabled -Validation bool -Value $true -Initialize -Description "Ola's Full System Database Backup should be enabled `$true or disabled `$false" +Set-PSFConfig -Module dbachecks -Name policy.ola.userfullenabled -Validation bool -Value $true -Initialize -Description "Ola's Full User Database Backup should be enabled `$true or disabled `$false" +Set-PSFConfig -Module dbachecks -Name policy.ola.userdiffenabled -Validation bool -Value $true -Initialize -Description "Ola's Diff User Database Backup should be enabled `$true or disabled `$false" +Set-PSFConfig -Module dbachecks -Name policy.ola.userlogenabled -Validation bool -Value $true -Initialize -Description "Ola's Log User Database Backup should be enabled `$true or disabled `$false" +Set-PSFConfig -Module dbachecks -Name policy.ola.systemfullscheduled -Validation bool -Value $true -Initialize -Description "Ola's Full System Database Backup should be scheduled `$true or disabled `$false" +Set-PSFConfig -Module dbachecks -Name policy.ola.userfullscheduled -Validation bool -Value $true -Initialize -Description "Ola's Full User Database Backup should be scheduled `$true or disabled `$false" +Set-PSFConfig -Module dbachecks -Name policy.ola.userdiffscheduled -Validation bool -Value $true -Initialize -Description "Ola's Diff User Database Backup should be scheduled `$true or disabled `$false" +Set-PSFConfig -Module dbachecks -Name policy.ola.userlogscheduled -Validation bool -Value $true -Initialize -Description "Ola's Log User Database Backup should be scheduled `$true or disabled `$false" +Set-PSFConfig -Module dbachecks -Name policy.ola.systemfullretention -Value 192 -Initialize -Description "Ola's Full System Database Backup retention number of hours" +Set-PSFConfig -Module dbachecks -Name policy.ola.userfullretention -Value 192 -Initialize -Description "Ola's Full User Database Backup retention number of hours" +Set-PSFConfig -Module dbachecks -Name policy.ola.userdiffretention -Value 192 -Initialize -Description "Ola's Diff User Database Backup retention number of hours" +Set-PSFConfig -Module dbachecks -Name policy.ola.userlogretention -Value 192 -Initialize -Description "Ola's Log User Database Backup retention number of hours" +Set-PSFConfig -Module dbachecks -Name policy.ola.CommandLogenabled -Validation bool -Value $true -Initialize -Description "Ola's CommandLog Cleanup should be enabled `$true or disabled `$false" +Set-PSFConfig -Module dbachecks -Name policy.ola.CommandLogscheduled -Validation bool -Value $true -Initialize -Description "Ola's CommandLog Cleanup should be scheduled `$true or disabled `$false" +Set-PSFConfig -Module dbachecks -Name policy.ola.CommandLogCleanUp -Value 30 -Initialize -Description "Ola's CommandLog Cleanup setting should be this many days" +Set-PSFConfig -Module dbachecks -Name policy.ola.SystemIntegrityCheckenabled -Validation bool -Value $true -Initialize -Description "Ola's System Database Integrity should be enabled `$true or disabled `$false" +Set-PSFConfig -Module dbachecks -Name policy.ola.SystemIntegrityCheckscheduled -Validation bool -Value $true -Initialize -Description "Ola's System Database Integrity should be scheduled `$true or disabled `$false" +Set-PSFConfig -Module dbachecks -Name policy.ola.UserIntegrityCheckenabled -Validation bool -Value $true -Initialize -Description "Ola's User Database Integrity should be enabled `$true or disabled `$false" +Set-PSFConfig -Module dbachecks -Name policy.ola.UserIntegrityCheckscheduled -Validation bool -Value $true -Initialize -Description "Ola's User Database Integrity should be scheduled `$true or disabled `$false" +Set-PSFConfig -Module dbachecks -Name policy.ola.UserIndexOptimizeenabled -Validation bool -Value $true -Initialize -Description "Ola's User Index Optimization should be enabled `$true or disabled `$false" +Set-PSFConfig -Module dbachecks -Name policy.ola.UserIndexOptimizescheduled -Validation bool -Value $true -Initialize -Description "Ola's User Index Optimization should be scheduled `$true or disabled `$false" +Set-PSFConfig -Module dbachecks -Name policy.ola.OutputFileCleanupenabled -Validation bool -Value $true -Initialize -Description "Ola's Output File Cleanup should be enabled `$true or disabled `$false" +Set-PSFConfig -Module dbachecks -Name policy.ola.OutputFileCleanupscheduled -Validation bool -Value $true -Initialize -Description "Ola's Output File Cleanup should be scheduled `$true or disabled `$false" +Set-PSFConfig -Module dbachecks -Name policy.ola.OutputFileCleanUp -Value 30 -Initialize -Description "Ola's OutputFile Cleanup setting should be this many days" +Set-PSFConfig -Module dbachecks -Name policy.ola.DeleteBackupHistoryenabled -Validation bool -Value $true -Initialize -Description "Ola's Delete Backup History should be enabled `$true or disabled `$false" +Set-PSFConfig -Module dbachecks -Name policy.ola.DeleteBackupHistoryscheduled -Validation bool -Value $true -Initialize -Description "Ola's Delete Backup History should be scheduled `$true or disabled `$false" +Set-PSFConfig -Module dbachecks -Name policy.ola.DeleteBackupHistoryCleanUp -Value 30 -Initialize -Description "Ola's Delete Backup History Cleanup setting should be this many days" +Set-PSFConfig -Module dbachecks -Name policy.ola.PurgeJobHistoryenabled -Validation bool -Value $true -Initialize -Description "Ola's Purge Job History should be enabled `$true or disabled `$false" +Set-PSFConfig -Module dbachecks -Name policy.ola.PurgeJobHistoryscheduled -Validation bool -Value $true -Initialize -Description "Ola's Purge Job History should be scheduled `$true or disabled `$false" +Set-PSFConfig -Module dbachecks -Name policy.ola.PurgeJobHistoryCleanUp -Value 30 -Initialize -Description "Ola's Purge Backup History Cleanup setting should be this many days" +Set-PSFConfig -Module dbachecks -Name ola.JobName.SystemFull -Value 'DatabaseBackup - SYSTEM_DATABASES - FULL' -Initialize -Description "The name for the Ola System Full Job" +Set-PSFConfig -Module dbachecks -Name ola.JobName.UserFull -Value 'DatabaseBackup - USER_DATABASES - FULL' -Initialize -Description "The name for the Ola User Full Job" +Set-PSFConfig -Module dbachecks -Name ola.JobName.UserDiff -Value 'DatabaseBackup - USER_DATABASES - DIFF' -Initialize -Description "The name for the Ola User Diff Job" +Set-PSFConfig -Module dbachecks -Name ola.JobName.UserLog -Value 'DatabaseBackup - USER_DATABASES - Log' -Initialize -Description "The name for the Ola User Log Job" +Set-PSFConfig -Module dbachecks -Name ola.JobName.CommandLogCleanup -Value 'CommandLog Cleanup' -Initialize -Description "The name for the Ola CommandLog Cleanup Job" +Set-PSFConfig -Module dbachecks -Name ola.JobName.SystemIntegrity -Value 'DatabaseIntegrityCheck - SYSTEM_DATABASES' -Initialize -Description "The name for the Ola System Integrity Job" +Set-PSFConfig -Module dbachecks -Name ola.JobName.UserIntegrity -Value 'DatabaseIntegrityCheck - USER_DATABASES' -Initialize -Description "The name for the Ola User Integrity Job" +Set-PSFConfig -Module dbachecks -Name ola.JobName.UserIndex -Value 'IndexOptimize - USER_DATABASES' -Initialize -Description "The name for the Ola User Index Job" +Set-PSFConfig -Module dbachecks -Name ola.JobName.OutputFileCleanup -Value 'Output File Cleanup' -Initialize -Description "The name for the Ola Output File Cleanup Job" +Set-PSFConfig -Module dbachecks -Name ola.JobName.DeleteBackupHistory -Value 'sp_delete_backuphistory' -Initialize -Description "The name for the Ola Delete Backup History Job" +Set-PSFConfig -Module dbachecks -Name ola.JobName.PurgeBackupHistory -Value 'sp_purge_jobhistory' -Initialize -Description "The name for the Ola Delete Purge History Job" # xevents Set-PSFConfig -Module dbachecks -Name policy.xevent.requiredexists -Value $null -Initialize -Description "List of XE Sessions that should exist. This does not check if they are running" @@ -230,16 +228,16 @@ Set-PSFConfig -Module dbachecks -Name policy.build.behind -Value $null -Initiali # 1 for Sunday 127 for every day # exclude databases -Set-PSFConfig -Module dbachecks -Name policy.asymmetrickeysize.excludedb -Value @('master', 'msdb', 'tempdb') -Initialize -Description "Databases to exclude from asymmetric key size checks" -Set-PSFConfig -Module dbachecks -Name policy.autoclose.excludedb -Value @() -Initialize -Description "Databases to exclude from autoclose key size checks" -Set-PSFConfig -Module dbachecks -Name policy.autoshrink.excludedb -Value @() -Initialize -Description "Databases to exclude from autoclose key size checks" -Set-PSFConfig -Module dbachecks -Name policy.vlf.excludedb -Value @('master', 'msdb', 'tempdb', 'model') -Initialize -Description "Databases to exclude from asymmetric key size checks" -Set-PSFConfig -Module dbachecks -Name policy.logfilecount.excludedb -Value @() -Initialize -Description "Databases to exclude from log file count checks" -Set-PSFConfig -Module dbachecks -Name policy.autocreatestats.excludedb -Value @() -Initialize -Description "Databases to exclude from the auto create stats checks" -Set-PSFConfig -Module dbachecks -Name policy.autoupdatestats.excludedb -Value @() -Initialize -Description "Databases to exclude from the auto update stats checks" -Set-PSFConfig -Module dbachecks -Name policy.autoupdatestatisticsasynchronously.excludedb -Value @() -Initialize -Description "Databases to exclude from the auto update stats asynchronously checks" -Set-PSFConfig -Module dbachecks -Name policy.database.statusexcludedb -Value @() -Initialize -Description "Databases to exclude from the database status checks" -Set-PSFConfig -Module dbachecks -Name policy.database.symmetrickeyencryptionlevelexcludedb -Value @('master', 'msdb', 'tempdb') -Initialize -Description "Databases to exclude from the Symmetric Key Encryption Level checks" +Set-PSFConfig -Module dbachecks -Name policy.asymmetrickeysize.excludedb -Value @('master', 'msdb', 'tempdb') -Initialize -Description "Databases to exclude from asymmetric key size checks" +Set-PSFConfig -Module dbachecks -Name policy.autoclose.excludedb -Value @() -Initialize -Description "Databases to exclude from autoclose key size checks" +Set-PSFConfig -Module dbachecks -Name policy.autoshrink.excludedb -Value @() -Initialize -Description "Databases to exclude from autoclose key size checks" +Set-PSFConfig -Module dbachecks -Name policy.vlf.excludedb -Value @('master', 'msdb', 'tempdb', 'model') -Initialize -Description "Databases to exclude from asymmetric key size checks" +Set-PSFConfig -Module dbachecks -Name policy.logfilecount.excludedb -Value @() -Initialize -Description "Databases to exclude from log file count checks" +Set-PSFConfig -Module dbachecks -Name policy.autocreatestats.excludedb -Value @() -Initialize -Description "Databases to exclude from the auto create stats checks" +Set-PSFConfig -Module dbachecks -Name policy.autoupdatestats.excludedb -Value @() -Initialize -Description "Databases to exclude from the auto update stats checks" +Set-PSFConfig -Module dbachecks -Name policy.autoupdatestatisticsasynchronously.excludedb -Value @() -Initialize -Description "Databases to exclude from the auto update stats asynchronously checks" +Set-PSFConfig -Module dbachecks -Name policy.database.statusexcludedb -Value @() -Initialize -Description "Databases to exclude from the database status checks" +Set-PSFConfig -Module dbachecks -Name policy.database.symmetrickeyencryptionlevelexcludedb -Value @('master', 'msdb', 'tempdb') -Initialize -Description "Databases to exclude from the Symmetric Key Encryption Level checks" @@ -380,8 +378,8 @@ Set-PSFConfig -Module dbachecks -Name domain.domaincontroller -Value $null -Init Set-PSFConfig -Module dbachecks -Name mail.failurethreshhold -Value 0 -Initialize -Description "Number of errors that must be present to generate an email report" Set-PSFConfig -Module dbachecks -Name mail.smtpserver -Value $null -Initialize -Description "Store the name of the smtp server to send email reports" Set-PSFConfig -Module dbachecks -Name mail.to -Value $null -Validation validation.EmailValidation -Initialize -Description "Email address to send the report to" -Set-PSFConfig -Module dbachecks -Name mail.from -Value $null -Validation validation.EmailValidation -Initialize -Description "Email address the email reports should come from" -Set-PSFConfig -Module dbachecks -Name mail.subject -Value 'dbachecks results' -Validation String -Initialize -Description "Subject line of the email report" +Set-PSFConfig -Module dbachecks -Name mail.from -Value $null -Validation validation.EmailValidation -Initialize -Description "Email address the email reports should come from" +Set-PSFConfig -Module dbachecks -Name mail.subject -Value 'dbachecks results' -Validation String -Initialize -Description "Subject line of the email report" # Command parameter default values Set-PSFConfig -Module dbachecks -Name command.invokedbccheck.excludecheck -Value @() -Initialize -Description "Invoke-DbcCheck: The checks that should be skipped by default." @@ -399,7 +397,7 @@ Set-PSFConfig -Module dbachecks -Name policy.server.cpuprioritisation -Value $tr Set-PSFConfig -Module dbachecks -Name policy.server.excludeDiskAllocationUnit -Value @() -Initialize -Description "The disks to skip from the Disk Allocation Unit check - Must be 'DISKLETTER:\'" # Devops -Set-PSFConfig -Module dbachecks -Name database.exists -Value @("master","msdb","tempdb","model") -Initialize -Description "The databases we expect to be on the instances" +Set-PSFConfig -Module dbachecks -Name database.exists -Value @("master", "msdb", "tempdb", "model") -Initialize -Description "The databases we expect to be on the instances" # Not Contactable Set-PSFConfig -Module dbachecks -Name global.notcontactable -Value @() -Initialize -Description "This is used within the checks to avoid trying to contact none-responsive instances many times - do not set manually" diff --git a/source/internal/functions/Invoke-ConfigurationScript.ps1 b/source/internal/functions/Invoke-ConfigurationScript.ps1 index 69c75692..15a91128 100644 --- a/source/internal/functions/Invoke-ConfigurationScript.ps1 +++ b/source/internal/functions/Invoke-ConfigurationScript.ps1 @@ -9,7 +9,7 @@ function Invoke-ConfigurationScript { #> [CmdletBinding()] param() - . $script:ModuleRoot\internal\configurations\configuration.ps1 + . (Convert-Path -Path $script:ModuleRoot\internal\configurations\configuration.ps1) } # SIG # Begin signature block diff --git a/source/internal/functions/New-Json.ps1 b/source/internal/functions/New-Json.ps1 index 095fb169..f8294688 100644 --- a/source/internal/functions/New-Json.ps1 +++ b/source/internal/functions/New-Json.ps1 @@ -7,7 +7,7 @@ function New-Json { $repos = Get-CheckRepo $collection = $groups = $repofiles = @() foreach ($repo in $repos) { - $repofiles += (Get-ChildItem "$repo\*.Tests.ps1") + $repofiles += (Get-ChildItem (Convert-Path -Path "$repo\*.Tests.ps1")) } $tokens = $null $errors = $null @@ -102,22 +102,17 @@ function New-Json { # CHoose the type if ($Describe.Parent -match "Get-Instance") { $type = "Sqlinstance" - } - elseif ($Describe.Parent -match "Get-ComputerName" -or $Describe.Parent -match "AllServerInfo") { + } elseif ($Describe.Parent -match "Get-ComputerName" -or $Describe.Parent -match "AllServerInfo") { $type = "ComputerName" - } - elseif ($Describe.Parent -match "Get-ClusterObject") { + } elseif ($Describe.Parent -match "Get-ClusterObject") { $Type = "ClusterNode" - } - else { + } else { #Choose the type from the new way from inside the foreach if ($ComputerNameForEach -match $title) { $type = "ComputerName" - } - elseif ($InstanceNameForEach -match $title) { + } elseif ($InstanceNameForEach -match $title) { $type = "Sqlinstance" - } - else { + } else { $type = $null } } @@ -125,8 +120,7 @@ function New-Json { if ($filename -eq 'HADR') { ## HADR configs are outside of describe $configs = [regex]::matches($check, "Get-DbcConfigValue\s([a-zA-Z\d]*.[a-zA-Z\d]*.[a-zA-Z\d]*.[a-zA-Z\d]*\b)").groups.Where{ $_.Name -eq 1 }.Value - } - else { + } else { $configs = [regex]::matches($describe.Parent.Extent.Text, "Get-DbcConfigValue\s([a-zA-Z\d]*.[a-zA-Z\d]*.[a-zA-Z\d]*.[a-zA-Z\d]*\b)").groups.Where{ $_.Name -eq 1 }.Value } $Config = '' @@ -202,7 +196,7 @@ function New-Json { } } $singletags = (($collection.AllTags -split ",").Trim() | Group-Object | Where-Object { $_.Count -eq 1 -and $_.Name -notin $groups }) - $Descriptions = Get-Content $script:ModuleRoot\internal\configurations\DbcCheckDescriptions.json -Raw | ConvertFrom-Json + $Descriptions = Get-Content (Convert-Path -Path $script:ModuleRoot\internal\configurations\DbcCheckDescriptions.json ) -Raw | ConvertFrom-Json foreach ($check in $collection) { $unique = $singletags | Where-Object { $_.Name -in ($check.AllTags -split ",").Trim() } $check.UniqueTag = $unique.Name @@ -210,10 +204,9 @@ function New-Json { } try { if ($PSCmdlet.ShouldProcess("$script:localapp\checks.json" , "Convert Json and write to file")) { - ConvertTo-Json -InputObject $collection | Out-File "$script:localapp\checks.json" + ConvertTo-Json -InputObject $collection | Out-File (Convert-Path -Path"$script:localapp\checks.json" ) } - } - catch { + } catch { Write-PSFMessage "Failed to create the json, something weird might happen now with tags and things" -Level Significant }