Install/Uninstall SQL Server via Command
Install/Uninstall SQL Server via Command
This is a post on installing SQL Server via command; I have a Windows Server 2016 Core running on a local Hyper-V test environment, and I’m installing SQL Server 2019, then uninstalling it.
There’s 4 parts to this one;
# Download a SQL Server ISO.
# Mount the ISO on a Hyper-V Virtual Machine.
# Install SQL Server via Command.
# Uninstall SQL Server via Command.
Download a SQL Server ISO
As this is on my test environment, I’m installing the most recent SQL Server Edition available, which is SQL Server 2019 CTP 2.4 at the time of writing.
SQL Server 2019 can be downloaded here – Open it up and select to download the media.
![SQL Server 2019 Download Media](https://peter-whyte.com/wp-content/uploads/2019/06/sql_server_2019_evaluation_download_media-1024x812.png)
ISO’s are good for local virtual environments (using HyperV here).
![SQL Server 2019 Download Media Type](https://peter-whyte.com/wp-content/uploads/2019/06/sql_server_2019_evaluation_media_type-1024x812.png)
6Mbps…
![SQL Server 2019 Download Speed](https://peter-whyte.com/wp-content/uploads/2019/06/sql_server_2019_evaluation_download_bandwidth-1024x812.png)
We’re now ready to get that ISO mounted.
Mount the ISO on a Hyper-V Virtual Machine
1. Click Media > Insert Disk…
![HyperV Insert Disk](https://peter-whyte.com/wp-content/uploads/2019/06/hyperv_insert_disk_gui.png)
2. Select the ISO file.
![SQL Server 2019 ISO File](https://peter-whyte.com/wp-content/uploads/2019/06/iso_selection-1024x392.png)
Install SQL Server via Command
1. First, lets have a look at our drives using the Get-PSDrive cmdlet.
![PowerShell Get-PSDrive](https://peter-whyte.com/wp-content/uploads/2019/06/get-psdrive.png)
2. Install using your preferred parameters. I’m adding the Domain Admins group as Sysadmins for quickness.
![SQL Server 2019 Install via Command](https://peter-whyte.com/wp-content/uploads/2019/06/sql_install.png)
3. We can look at the Summary.txt file using Get-Content to verify the installation has been successful.
![PowerShell Get-Content SQL Summary File](https://peter-whyte.com/wp-content/uploads/2019/06/summary_p1.png)
![PowerShell Get-Content SQL Summary](https://peter-whyte.com/wp-content/uploads/2019/06/summary_p2.png)
The above shows the result of the installation was successful, and other things like where the Configuration INI file is (used for Unattended Installs).
4. Next, we should check the SQL Server services, using Get-Service with “SQL” wrapped in wildcards.
![PowerShell Get-Service](https://peter-whyte.com/wp-content/uploads/2019/06/get-service.png)
Uninstall SQL Server via Command
Uninstalling is as simple as the install, funnily enough..
![SQL Server 2019 Uninstall via Command](https://peter-whyte.com/wp-content/uploads/2019/06/sql_uninstall.png)
Once it’s done, we can check the summary file status and services to quickly verify the uninstallation has not been unsuccessful.
0 Comments