Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
54 changes: 44 additions & 10 deletions dbatools.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ whether the modulebase has been set (first thing it does after loading library t
Theoretically, there's a minor cuncurrency collision risk with that, but since the cost is only
a little import time loss if that happens ...
#>
Import-Command -Path "$script:psScriptRoot/internal/scripts/libraryimport.ps1"
Import-Command -Path "$script:psScriptRoot/private/scripts/libraryimport.ps1"
Write-ImportTime -Text "Initial import of SMO libraries"

Import-Command -Path "$psScriptRoot/bin/typealiases.ps1"
Expand Down Expand Up @@ -168,14 +168,14 @@ Write-ImportTime -Text "Checking for debugging preference"

if (-not (Test-Path -Path "$psScriptRoot\dbatools.dat") -or $script:serialimport) {
# All internal functions privately available within the toolset
foreach ($file in (Get-ChildItem -Path "$psScriptRoot/internal/functions/" -Recurse -Filter *.ps1)) {
foreach ($file in (Get-ChildItem -Path "$psScriptRoot/private/functions/" -Recurse -Filter *.ps1)) {
. $file.FullName
}

Write-ImportTime -Text "Loading internal commands via dotsource"

# All exported functions
foreach ($file in (Get-ChildItem -Path "$script:PSModuleRoot/functions/" -Recurse -Filter *.ps1)) {
foreach ($file in (Get-ChildItem -Path "$script:PSModuleRoot/public/" -Recurse -Filter *.ps1)) {
. $file.FullName
}

Expand All @@ -187,7 +187,7 @@ if (-not (Test-Path -Path "$psScriptRoot\dbatools.dat") -or $script:serialimport

# Load configuration system - Should always go after library and path setting
# this has its own Write-ImportTimes
Import-Command -Path "$psScriptRoot/internal/configurations/configuration.ps1"
Import-Command -Path "$psScriptRoot/private/configurations/configuration.ps1"

# Resolving the path was causing trouble when it didn't exist yet
# Not converting the path separators based on OS was also an issue.
Expand All @@ -201,33 +201,33 @@ if (-not ([Dataplat.Dbatools.Message.LogHost]::LoggingPath)) {
# Validations were moved into the other files, in order to prevent having to update dbatools.psm1 every time

if ($PSVersionTable.PSVersion.Major -lt 5) {
foreach ($file in (Get-ChildItem -Path "$script:PSScriptRoot/optional" -Filter *.ps1)) {
foreach ($file in (Get-ChildItem -Path "$script:PSScriptRoot/opt" -Filter *.ps1)) {
Import-Command -Path $file.FullName
}
Write-ImportTime -Text "Loading Optional Commands"
}

# Process TEPP parameters
Import-Command -Path "$psScriptRoot/internal/scripts/insertTepp.ps1"
Import-Command -Path "$psScriptRoot/private/scripts/insertTepp.ps1"
Write-ImportTime -Text "Loading TEPP"

# Process transforms
Import-Command -Path "$psScriptRoot/internal/scripts/message-transforms.ps1"
Import-Command -Path "$psScriptRoot/private/scripts/message-transforms.ps1"
Write-ImportTime -Text "Loading Message Transforms"

# Load scripts that must be individually run at the end #
#-------------------------------------------------------#

# Start the logging system (requires the configuration system up and running)
Import-Command -Path "$psScriptRoot/internal/scripts/logfilescript.ps1"
Import-Command -Path "$psScriptRoot/private/scripts/logfilescript.ps1"
Write-ImportTime -Text "Loading Script: Logging"

# Start the tepp asynchronous update system (requires the configuration system up and running)
Import-Command -Path "$psScriptRoot/internal/scripts/updateTeppAsync.ps1"
Import-Command -Path "$psScriptRoot/private/scripts/updateTeppAsync.ps1"
Write-ImportTime -Text "Loading Script: Asynchronous TEPP Cache"

# Start the maintenance system (requires pretty much everything else already up and running)
Import-Command -Path "$psScriptRoot/internal/scripts/dbatools-maintenance.ps1"
Import-Command -Path "$psScriptRoot/private/scripts/dbatools-maintenance.ps1"
Write-ImportTime -Text "Loading Script: Maintenance"

# New 3-char aliases
Expand Down Expand Up @@ -1024,4 +1024,38 @@ Write-ImportTime -Text "Checking for some ISE stuff"
# Create collection for servers
$script:connectionhash = @{ }


if (Get-DbatoolsConfigValue -FullName Import.EncryptionMessageCheck) {
$trustcert = Get-DbatoolsConfigValue -FullName sql.connection.trustcert
$encrypt = Get-DbatoolsConfigValue -FullName sql.connection.encrypt
if (-not $trustcert -or $encrypt -in "Mandatory", "$true") {
# keep it write-host for psv3
Write-Message -Level Output -Message '
/ / / /
| O | | O |
| |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -| |
| O | | O |
| | | |
| O | | O |
| | C O M P U T E R | |
| O | | O |
| | M E S S A G E | |
| O | | O |
| | | |
| O |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -| O |
| | | |

Microsoft changed the encryption defaults in their SqlClient library, which may
cause your connections to fail.

You can change the defaults with Set-DbatoolsConfig but dbatools also makes it
easy to setup encryption. Check out dbatools.io/newdefaults for more information.

To disable this message, run:

Set-DbatoolsConfig -Name Import.EncryptionMessageCheck -Value $false -PassThru |
Register-DbatoolsConfig'
}
}

[Dataplat.Dbatools.dbaSystem.SystemHost]::ModuleImported = $true
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ if (($PSVersionTable.PSVersion.Major -ge 6) -and ($PSVersionTable.OS -notlike "*
$script:NoRegistry = $true
}

$configpath = [IO.Path]::Combine($script:PSModuleRoot, "internal", "configurations")
$configpath = [IO.Path]::Combine($script:PSModuleRoot, "private", "configurations")
Write-ImportTime -Text "Config system: Set more paths and special paths"
# Import configuration validation
foreach ($file in (Get-ChildItem -Path ([IO.Path]::Combine($configpath, "validation")))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,7 @@ Set-DbatoolsConfig -Name 'Import.SerialImport' -Value $false -Initialize -Valida
} -Description "Enabling this will cause the module to perform import in a serial manner, not parallelizing anything. This will impose a significant delay on import, but reduces the CPU impact during import. Setting this for an unattended script may be useful to avoid resource alerts. Can be set on script level by placing the following code in the first line: '`$dbatools_serialimport = `$true'. This configuration setting persists across all PowerShell consoles for this user."

# Check for SqlPs
Set-DbatoolsConfig -Name 'Import.SqlpsCheck' -Value $true -Initialize -Validation bool -Description "Does not warn about sqlps being imported at the time of the dbatools import"
Set-DbatoolsConfig -Name 'Import.SqlpsCheck' -Value $true -Initialize -Validation bool -Description "Does not warn about sqlps being imported at the time of the dbatools import"

# Check for Encryption
Set-DbatoolsConfig -Name 'Import.EncryptionMessageCheck' -Value $true -Initialize -Validation bool -Description "Does not warn about new Microsoft encryption defaults"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ function Get-DbaHelp {
}
$null = $rtn.Add('')
$null = $rtn.Add("`n" + ' ' + "`n")
$null = $rtn.Add('Want to see the source code for this command? Check out [' + $doc_to_render.CommandName + '](https://github.com/dataplat/dbatools/blob/master/functions/' + $doc_to_render.CommandName + '.ps1) on GitHub.')
$null = $rtn.Add('Want to see the source code for this command? Check out [' + $doc_to_render.CommandName + '](https://github.com/dataplat/dbatools/blob/master/public/' + $doc_to_render.CommandName + '.ps1) on GitHub.')
$null = $rtn.Add("<br>")
$null = $rtn.Add('Want to see the Bill Of Health for this command? Check out [' + $doc_to_render.CommandName + '](https://dataplat.github.io/boh#' + $doc_to_render.CommandName + ').')
$null = $rtn.Add('')
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function Invoke-TagCommand ([string]$Tag, [string]$Keyword) {
$tagsRex = ([regex]'(?m)^[\s]{0,15}Tags:(.*)$')
$modulepath = (Get-Module -Name dbatools).Path
$directory = Split-Path $modulepath
$basedir = "$directory\functions\"
$basedir = "$directory\public\"
Import-Module $modulepath -force
$allfiles = Get-ChildItem $basedir
foreach ($f in $allfiles) {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
$scriptBlock = {
$ModuleRoot = [Dataplat.Dbatools.dbaSystem.SystemHost]::ModuleBase

$ExecutionContext.InvokeCommand.InvokeScript($false, ([scriptblock]::Create([io.file]::ReadAllText((Resolve-Path "$ModuleRoot\internal\functions\tabcompletion\Register-DbaTeppScriptblock.ps1").ProviderPath))), $null, $null)
$ExecutionContext.InvokeCommand.InvokeScript($false, ([scriptblock]::Create([io.file]::ReadAllText((Resolve-Path "$ModuleRoot\internal\functions\tabcompletion\Register-DbaTeppInstanceCacheBuilder.ps1").ProviderPath))), $null, $null)
$ExecutionContext.InvokeCommand.InvokeScript($false, ([scriptblock]::Create([io.file]::ReadAllText((Resolve-Path "$ModuleRoot\private\functions\tabcompletion\Register-DbaTeppScriptblock.ps1").ProviderPath))), $null, $null)
$ExecutionContext.InvokeCommand.InvokeScript($false, ([scriptblock]::Create([io.file]::ReadAllText((Resolve-Path "$ModuleRoot\private\functions\tabcompletion\Register-DbaTeppInstanceCacheBuilder.ps1").ProviderPath))), $null, $null)

foreach ($file in (Get-ChildItem (Resolve-Path "$ModuleRoot\internal\dynamicparams\*.ps1").ProviderPath)) {
foreach ($file in (Get-ChildItem (Resolve-Path "$ModuleRoot\private\dynamicparams\*.ps1").ProviderPath)) {
$ExecutionContext.InvokeCommand.InvokeScript($false, ([scriptblock]::Create([io.file]::ReadAllText($file.FullName))), $null, $null)
}

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
foreach ($item in (Get-ChildItem "$script:PSModuleRoot\internal\maintenance" -Filter *.ps1)) {
foreach ($item in (Get-ChildItem "$script:PSModuleRoot\private\maintenance" -Filter *.ps1)) {
if ($script:serialimport) {
. $item.FullName
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading