Skip to content

Conversation

@frodr1k
Copy link

@frodr1k frodr1k commented Dec 2, 2025

This implements a new function to remotely deploy dbatools module to servers. I had to give my idea a go to see it it was feasible to do this. I used help from Claude in order to see how well it would turn out. Used it on some production jump hosts today.

Features:

  • Supports both PSRemoting and admin share deployment methods
  • Works in air-gapped environments using -UseAdminShare
  • Includes comprehensive help documentation with 5 examples
  • Fully tested with Pester 5 tests
  • Standalone compatible (works when dot-sourced)

What is your stance on this one?

Type of Change

  • Bug fix (non-breaking change, fixes # )
  • New feature (non-breaking change, adds functionality, fixes invoke-dbatoolsremoteupgrade - Push DbaTools to non internet connected servers. #10023)
  • Breaking change (affects multiple commands or functionality, fixes # )
  • Ran manual Pester test and has passed (Invoke-ManualPester)
  • Adding code coverage to existing functionality
  • Pester test is included
  • If new file reference added for test, has is been added to github.com/dataplat/appveyor-lab ?
  • Unit test is included
  • Documentation
  • Build system

Purpose

This PR adds a new function Update-DbaToolsModule to remotely deploy dbatools module to multiple servers. This addresses the need for updating dbatools in air-gapped or non-internet-connected environments where servers cannot download modules directly from PowerShell Gallery.

Approach

The function provides two deployment methods:

  1. PSRemoting (default): Full verification with remote module testing
  2. Admin Share (-UseAdminShare): File copy via UNC paths (\server\C$) for environments without PSRemoting

The implementation includes:

  • Helper functions for standalone compatibility
  • Pipeline support for mass deployments
  • Proper error handling with continue-on-error for multiple computers
  • SupportsShouldProcess for safety
  • Comprehensive help with 5 practical examples

Commands to test

Examples are included in the help documentation. Basic tests:

# Test 1: Deploy using admin share (requires local admin rights)
Update-DbaToolsModule -ComputerName SQL01 -UseAdminShare -SourcePath "C:\Program Files\WindowsPowerShell\Modules\dbatools\2.7.12"

# Test 2: Deploy using PSRemoting (requires WinRM enabled)
Update-DbaToolsModule -ComputerName SQL01 -Credential $cred

# Test 3: Pipeline from CMS
Get-DbaRegServer -SqlInstance CMS | Update-DbaToolsModule -UseAdminShare -SourcePath \\share\dbatools\2.7.12

# Test 4: Multiple servers
Update-DbaToolsModule -ComputerName SQL01, SQL02, SQL03 -UseAdminShare -SourcePath "C:\Modules\dbatools\2.7.12"

# Test 5: WhatIf to preview
Update-DbaToolsModule -ComputerName SQL01 -UseAdminShare -SourcePath "C:\Modules\dbatools\2.7.12" -WhatIf

This implements a new function to remotely deploy dbatools module to servers.

Features:
- Supports both PSRemoting and admin share deployment methods
- Works in air-gapped environments using -UseAdminShare
- Includes comprehensive help documentation with 5 examples
- Fully tested with Pester 5 tests
- Standalone compatible (works when dot-sourced)

What is your stance on this one?
- Changed ComputerName parameter from [string[]] to [DbaInstanceParameter[]]
- Fixed Stop-Function helper with proper [switch]$Continue parameter
- Updated SupportsShouldProcess test to check ScriptBlock.Attributes
- Fixed error handling tests to match dbatools patterns
- Applied OTBS formatting to both function and test files
- Added function to FunctionsToExport in dbatools.psd1

All 26 tests passing, PSScriptAnalyzer clean
@frodr1k
Copy link
Author

frodr1k commented Dec 3, 2025

updated

  • Changed ComputerName parameter from [string[]] to [DbaInstanceParameter[]]
  • Fixed Stop-Function helper with proper [switch]`$Continue parameter
  • Updated SupportsShouldProcess test to check ScriptBlock.Attributes
  • Fixed error handling tests to match dbatools patterns
  • Applied OTBS formatting to both function and test files
  • Added function to FunctionsToExport in dbatools.psd1

All 26 tests passing, PSScriptAnalyzer clean"

@potatoqualitee
Copy link
Member

Thank you for your PR, @frodr1k ! I am hesitant about adding a command for this because we generally suggest not installing dbatools across a fleet, as most management should occur from a limited number of servers. That said, I usually work with smaller networks and don't even know how people manage like 3000 SQL Servers.

In our offline networks, we set repos using GPO and used file shares to replicate the PS Gallery.

Further, a request would then be made for Install-Dbatools.

The pros of this is that if you found it useful, others may too. And I do like to encourage commands and modules that keep systems up-to-date. That said, I'm leaning to suggesting you make this a general module like OffflineInstaller then we'd welcome you to post about its use on dbatools.io/blog. I write about offline scenarios (https://dbatools.io/offline), and your module could take that a step further.

@niphlod and @andreasjordan if you're around, what do you think?

@andreasjordan
Copy link
Collaborator

Some thoughts:

  • dbatools should only be installed on a few central systems by official methods used in the company, so I don't see the need of this command
  • have I missed dbatools.library or is it only installing dbatools itself?
  • @FriedrichWeinmann has a module or command to do this kind of things with his modules. Maybe have a look at that code as well.

@potatoqualitee
Copy link
Member

ah confirmed, thank you @andreasjordan. @frodr1k we really appreciate the PR but it is not in scope :/ we are open to a blog post however.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

invoke-dbatoolsremoteupgrade - Push DbaTools to non internet connected servers.

3 participants