# offline installs of dbatools

If you work in a secure environment or your computers cannot access the Internet for any reason, you can still install dbatools with ease by downloading the zip from a workstation that does have Internet access 🌈 And now that our module is digitally signed, you can keep your Execution Policy set to AllSigned, too.

There are essentially 3 ways to get the zip of our module

1. From PowerShell Gallery using Save-Module

Once the file has been downloaded, copy it to your secure server and place it in one of the directories in your $env:PSModulePath (type $env:PSModulePath at the prompt and press enter). This will allow PowerShell to autoload the module, saving you from having to Import-Module each time you start a new session.

## PowerShell Gallery

PowerShell Gallery is Microsoft’s official repository for PowerShell modules and scripts. It’s likely unblocked at your organization, so using the Gallery is a great option.

#### Method 1

If you run Windows 10 or Windows Server 2016, you’ve already got support for the Gallery and can just issue the following command.

Save-Module -Name dbatools -Path C:\temp

This will download the package, unzip it and place it into C:\temp\dbatools. Saving modules and investigating their content is actually a recommended practice by the PowerShell team, as it’s always good to know what you’re installing on your system.

#### Method 2

If your system is older and you do not have PowerShellGet or you haven’t upgraded to PowerShell 5.1 (which comes with PowerShellGet), then you can just download the zip directly from the Gallery’s API.

Note that this will download a file ending in .nupkg. Simply rename the file to .zip, extract and you’re set. You can also use PowerShell to download the module and rename it, all in one shot.

Invoke-WebRequest -Uri powershellgallery.com/api/v2/package/dbatools -OutFile c:\temp\dbatools.zip

Invoke-WebRequest is a bit slow, however, because of the progress bar, so I usually just download via GUI and rename.

## GitHub via dbatools.io/zip

This is just an easy-to-remember redirector to GitHub’s repo zip.

Note that there is a small difference between our GitHub repo and the PowerShell Gallery. The GitHub repo does not include a pre-compiled version of our library (dbatools.dll), while the PowerShell Gallery does. Ultimately, both ways work and there’s really no difference. Excluding the dll from the GitHub repo just made it easier for our developers to avoid conflicts.

Once you’ve extracted the folder, make sure you rename it from dbatools-master or dbatools-development to plain o’ dbatools.

## Unblocking DLLs

Our .psm1 takes care of Unblocking DLLs, but if you use the download and unzip method for other PowerShell modules, keep in mind that the DLLs will likely be blocked by default. If this happens, simply run

Get-ChildItem -Recurse C:\path\to\module | Unblock-File

## $env:PSMODULEPATH Just a quick note about $env:PSMODULEPATH. If you’re not familiar with PSMODULEPATH, you may remember PATH from the DOS days and PSMODULEPATH is similar. Any module placed within your $env:PSMODULEPATH will automatically load once you execute a command from that module. Here, you can see the contents of my path and that I manually added my git repo. Thanks for reading, - Chrissy ### 11 thoughts on “offline installs of dbatools” 1. Brian Love Reply I’ve read much of the site and have just installed the tools. This looks very exciting! 2. Adolfo Martinez Jr Reply I’ve installed dbatools via the offline method of zipping and unzipping and then renaming the module to dba tools. Apparently the module shows as available in my session when I run Get-Module. However, there are no available commands to execute. How can I solve this problem? 3. Rex Reply Ugh. Have 2008R2 Servers, pplanning for upgrade and consolidation. Was told about the tools by a peer and began loading to access our SQL server as the topology and AD resides in a different “AD tree” as my work station i had to perform some actions on my DB server. 1st, had to upgrade Framework 1st, then install new Powershell, was able to past the signing and a block on the module, then it showed up in powershell ISE last night. I dropped out of the ISE modules not showing now. WTF. Stuck Now, tried to reload and getting smo dll error when trying to re-run installer. Documentation on doing the installs would. Especially as it relates to transitioning legacy systems. • Chrissy LeMaire Post authorReply check out dbatools.io/soup2nutz in your case, remove everything (uninstall-module or delete from your directories) and try again. Also, I highly recommend using the console (powershell.exe) as opposed to the ISE. If you need a visual, vs code is more desirable. 4. Andrew Calvett Reply Hi, I wanted to share the solution to a problem I had with the install to save other people time. My environment is locked down so i had to follow the manual download process and copy the module to one of the modules folders set per$env:PSModulePath.

As i don’t have local admin i could only copy to a modules folder defined on a share but when i installed the module it would fail with “Exception calling “ReadAllText” with “1” argument(s): “The given path’s format is not supported.” ”

Some testing showed i could use a local path or a mapped drive and dbatools would load, i could have stuck with import-module but i wanted all the auto loading goodness so it needed to be in PSModulePath but initially i could not edit that path because i did not have admin access to get at it through the control panel.

A little more digging led me back to powershell and a one liner to add the path to PSModulePath and happy days!

The command was: \$env:PSModulePath += “;”

Hope this is useful for someone else!

Cheers

Andrew