Introduction

Let’s talk about getting your favorite toolbelt into a new database environment, your new jump box or VM that is based on a Window Server OS. This blog post is going to talk about it getting your favorite software using PowerShell without using an Internet browser.

For me personally, I like to have the same tools everywhere I go. Tools (I often call it a toolbelt) that I know how to use, tools that are making me more productive/efficient and preferably tools that have a price tag of free. My favorite toolbelt for SQL Server consists of the following software packages:

Problem

While I don’t know enough about Linux, I do know enough about Windows. Unfortunately, Windows Server is still shipped with an Internet Explorer (a.k.a. IE) making it the only browser that is available. Even more unfortunate, IE is nothing but a plain pain (a.k.a. PP) to use. IE doesn’t make anything easy, especially when its installed on a server with a corporate group policy (a.k.a. GP) that is making downloads extremely painful.

Try to download anything external to a Windows Server with Internet Explorer and you will see high level of PP. It’s like this browser is trying to keep you in the dark from all the modern progress by reminding you (Fig #1) what you are not allowed to experience it due to “some” security! 🙂

Fig #1

Solution

While you can’t control which internet browser Microsoft ships with Windows Server and it’s a bit difficult to change GP, you can completely skip using IE for downloads – introducing PowerShell (a.k.a. PS).

PS cmdlets will let you download anything that you want (your corporate security policies still apply here), so you can add your toolbelt to new environment, easy-peasy. You don’t need to know much PS syntax (everything revolves around $client.DownloadFile) and virtually all Windows Servers are shipped with PowerShell, so let’s see how easy it really is.

All you need is to incorporate the following code into a ps1 file and run it. You can use Windows PowerShell ISE (see Fig #2) or VS Code or alternatively you can run line by line from a PowerShell Command Prompt (see Fig #3).

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$client = new-object System.Net.WebClient

#test download datasteve image
#$client.DownloadFile(“https://steverezhener.files.wordpress.com/2019/12/datasteve-sm.jpg?w=107”,“C:\Users\Steve.Rezhener\Pictures\datasteve.jpg”)

#download Edge Chromium
$client.DownloadFile(“http://dl.delivery.mp.microsoft.com/filestreamingservice/files/789ec525-0feb-4d62-a24b-99fd15d117e4/MicrosoftEdgeEnterpriseX64.msi”,“C:\Users\Steve.Rezhener\Downloads\MicrosoftEdgeEnterpriseX64.msi”)

#download SSMS
$client.DownloadFile(“https://aka.ms/ssmsfullsetup”,“C:\Users\Steve.Rezhener\Downloads\ssms-setup-enu.exe”)

#download Red Gate SQL Search
$client.DownloadFile(“https://download.red-gate.com/SQL_Search.exe”,“C:\Users\Steve.Rezhener\Downloads\SQL_Search.exe”)

#download SentryOne Plan Explorer
$client.DownloadFile(“https://downloads.sentryone.com/downloads/sqlsentryplanexplorer/x64/PlanExplorerInstaller.exe”,“C:\Users\Steve.Rezhener\Downloads\PlanExplorerInstaller.exe”)

#download ApexSQL Refactor
$client.DownloadFile(“https://www.apexsql.com/zips/ApexSQLRefactor.exe”,“C:\Users\Steve.Rezhener\Downloads\ApexSQLRefactor.exe”)
Fig #2
Fig #3

If you are using Windows PowerShell ISE, just click the play button, wait for about 30 seconds and enjoy my toolbelt (see Fig #4) or feel free to change my code to download anything else you need and bypass the IE.

Fig #4

Enjoy installing and using the software.

Disclaimer

This blog post is partially based on following resources: https://www.thewindowsclub.com/download-file-using-windows-powershell