In order to execute the first time, PackageManagement requires an internet connection to download the Nuget package provider. However, if your computer does not have an internet connection and you need to use the Nuget or PowerShellGet provider, you can download them on another computer and copy them to your target computer. Use the following steps to do this:
- Open PowerShell (as Admin)
- Run the following to set powershell to TLS 1.2:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
If you run Windows 10 or Windows Server 2016, you’ve already got support for the Gallery and can just issue the following command. This will download the package, unzip it into C:\temp\dbatools folder. Temp folder must exist for this to work. If temp folder does not exist, please create one before running the below script
Save-Module -Name dbatools -Path C:\temp
Keep in mind that the DLLs will likely be blocked by default. If this happens, simply run
Get-ChildItem -Recurse C:\temp | Unblock-File
Copy the dbatools folder from C:\temp to C:\Program Files\WindowsPowerShell\Modules folder
Open PS or command prompt and run the below command: $env:PSMODULEPATH
Any module placed within your $env:PSMODULEPATH will automatically load once you execute a command from the module
Run the following command to test the import of dbatools PS module:
Import-Module dbatools
It should run without any errors. You are now free to proceed to run any of the dbatools PS modules for DBA administrative tasks.