powershell 安装SQL 2016 Dev命令行(Powershell)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell 安装SQL 2016 Dev命令行(Powershell)相关的知识,希望对你有一定的参考价值。

#Uninstalls a standard CashConverter SQL Server local installation.
# Also removes all database files. i.e. should be a clean uninstall
# Install SQL from command line help - https://msdn.microsoft.com/en-us/library/ms144259.aspx
$sw = [Diagnostics.Stopwatch]::StartNew()
$currentUserName = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name;
$SqlServerIsoImagePath = "???\Downloads\Microsoft\SQL Server 2016 Developer Edition\en_sql_server_2016_developer_x64_dvd_8777069.iso"

#Mount the installation media, and change to the mounted Drive.
$mountVolume = Mount-DiskImage -ImagePath $SqlServerIsoImagePath -PassThru
$driveLetter = ($mountVolume | Get-Volume).DriveLetter
$drivePath = $driveLetter + ":"
push-location -path "$drivePath"

#Install SQL Server locally with our default settings. 
# Assumes only the Sql Engine and LocalDB were installed
.\Setup.exe /q /ACTION=UNINSTALL /FEATURES=SQLEngine, LocalDB /INSTANCENAME=MSSQLSERVER

#Dismount the installation media.
pop-location
Dismount-DiskImage -ImagePath $SqlServerIsoImagePath

#Clear out the orphaned database files
# As per the install script INSTANCENAME=MSSQLSERVER & INSTANCEDIR="C:\Program Files\Microsoft SQL Server"
Remove-Item -Recurse -Force "C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\"


#print Time taken to execute
$sw.Stop()
"Sql install script completed in {0:c}" -f $sw.Elapsed;
#Installs SQL Server locally with standard settings for Developers/Testers.
# Install SQL from command line help - https://msdn.microsoft.com/en-us/library/ms144259.aspx
$sw = [Diagnostics.Stopwatch]::StartNew()
$currentUserName = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name;
$SqlServerIsoImagePath = "???\Downloads\Microsoft\SQL Server 2016 Developer Edition\en_sql_server_2016_developer_x64_dvd_8777069.iso"

#Mount the installation media, and change to the mounted Drive.
$mountVolume = Mount-DiskImage -ImagePath $SqlServerIsoImagePath -PassThru
$driveLetter = ($mountVolume | Get-Volume).DriveLetter
$drivePath = $driveLetter + ":"
push-location -path "$drivePath"

#Install SQL Server locally with our default settings. 
# Only the Sql Engine and LocalDB
# i.e. no Replication, FullText, Data Quality, PolyBase, R, AnalysisServices, Reporting Services, Integration service, Master Data Services, Books Online(BOL) or SDK are installed.
.\Setup.exe /q /ACTION=Install /FEATURES=SQLEngine, LocalDB /UpdateEnabled /UpdateSource=MU /X86=false /INSTANCENAME=MSSQLSERVER /INSTALLSHAREDDIR="C:\Program Files\Microsoft SQL Server" /INSTALLSHAREDWOWDIR="C:\Program Files (x86)\Microsoft SQL Server" /SQLSVCINSTANTFILEINIT="True" /INSTANCEDIR="C:\Program Files\Microsoft SQL Server" /AGTSVCACCOUNT="NT Service\SQLSERVERAGENT" /AGTSVCSTARTUPTYPE="Manual" /SQLSVCSTARTUPTYPE="Automatic" /SQLCOLLATION="SQL_Latin1_General_CP1_CI_AS" /SQLSVCACCOUNT="NT Service\MSSQLSERVER" /SECURITYMODE="SQL" /SAPWD="Passw0rd" /SQLSYSADMINACCOUNTS="$currentUserName" /IACCEPTSQLSERVERLICENSETERMS

#Dismount the installation media.
pop-location
Dismount-DiskImage -ImagePath $SqlServerIsoImagePath

#print Time taken to execute
$sw.Stop()
"Sql install script completed in {0:c}" -f $sw.Elapsed;

以上是关于powershell 安装SQL 2016 Dev命令行(Powershell)的主要内容,如果未能解决你的问题,请参考以下文章

通过 PowerShell 从本地 SQL Server 2016 将 dacpac 发布到 Azure SQL 托管实例失败“无法发布到 SQL Server 2014”

powershell Powershell - 安装Sql Server Management Studio

为啥安装sql Server 2008时总是显示windows powershell错误?

SQL2008安装出错(Windows PowerShell未能安装)

powershell Home Assistant安装在Windows 2016 NanoServer上

如何在 SQL Server docker 映像之上安装 PowerShell Core?