This guide provides detailed instructions for installing dbatools on a machine without internet access. dbatools is a comprehensive suite of PowerShell tools designed to help SQL Server professionals efficiently manage SQL Server instances.
Introduction
Requirements
- Source Computer: A computer with internet access for downloading dbatools.
- Target Computer: The offline computer where dbatools will be installed.
- PowerShell v5.1 or higher: Installed on the target computer.
- USB Drive or other transfer media: For transferring the dbatools module from the source to the target computer.
Step 1: Download dbatools Package
On the source computer with internet access:
1.1 Install dbatools (if not already installed):
Open PowerShell as Administrator and execute the following command:
Install-Module -Name dbatools
1.2 Export the dbatools module:
Create a directory (C:\Temp\dbatools)
to export the module, then run:
Save-Module -Name dbatools -Path C:\Temp\dbatools
This command saves the dbatools module and all its dependencies into the specified path.
Step 2: Transfer the dbatools Package
2.1 Copy the exported dbatools folder:
Transfer the entire contents of C:\Temp\dbatools
to your USB drive or other media.
2.2 Connect the transfer media to the target computer.
Step 3: Install dbatools on the Target Computer
Follow these steps on the target computer:
3.1 Copy the dbatools folder from the transfer media:
Copy the dbatools module folder from your USB drive to a path on the target computer (most probably, C:\Program Files\WindowsPowerShell\Modules)
3.2 Import the dbatools module:
Open PowerShell as Administrator on the target computer and execute the following commands.:
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Bypass (Click "Yes to all")
Import-Module dbatools
Step 4: Verify the Installation
To ensure that dbatools has been installed correctly and is operational, run the following command:
Get-Command -Module dbatools
This command will list all the commands available in the dbatools module, indicating that the module is loaded and functional.
Troubleshooting
If you encounter any issues during the installation, consider the following steps:
- Check Module Dependencies: Make sure all required dependencies of dbatools are included in the transfer. These should have been downloaded when using
Save-Module
. - Execution Policy: If there are issues importing the module due to PowerShell’s execution policy, adjust it by running:
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Bypass -Force
This setting temporarily bypasses the execution policy for the current PowerShell session.
Conclusion
By following this guide, you can successfully set up dbatools on a computer without internet access. This enables SQL Server professionals to utilize powerful management tools in environments with strict security controls or restricted internet access.