How to use PowerShell to get your toolbelt into a Windows Server

Introduction

This post describes how to use PowerShell to get your favorite toolbelt into a new database environment, your new jump box or VM that is based on a Window Server OS, 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 available to you. Even more unfortunate, IE is nothing but a plain pain (a.k.a. PP) to use. IE doesn’t make anything easy, especially when it’s 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 a high level of PP. It’s like this browser is trying to keep you insulated from modern progress by reminding you (Fig #1) what you are not allowed to experience due to “some” security! 

How to use PowerShell to get your toolbelt into a Windows Server without a browser
Figure 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 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). This is how to use PowerShell to add your toolbelt to a new environment, easy-peasy. You don’t need to know much PS syntax 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(“https://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”)
Figure 2
Figure 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.

Figure 4

Enjoy installing and using the software.

Disclaimer

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