sql-server - 远程安装 SQL Server
问题描述
我正在尝试使用 PowerShell 在远程计算机上安装 SQL Server 2016。下面是我的脚本。有人可以帮助确定问题。
# Variables
$INSTANCENAME = 'DB1234INST01'
$VOLNAME = '1234INST01'
$SAPASS = "abc@12345"
$InstMem = '4096'
Invoke-Command -ComputerName DB12345 -ScriptBlock{
# Install SQL Instance
D:\Setup.exe `
/SkipRules=RebootRequiredCheck `
/ACTION=Install `
/AGTSVCSTARTUPTYPE=Automatic `
/BROWSERSVCSTARTUPTYPE=Automatic `
/ERRORREPORTING=False `
/FEATURES="SQLEngine,DQ" `
/IACCEPTSQLSERVERLICENSETERMS `
/INSTANCEDIR="E:\$VOLNAME" `
/INSTANCEID=$INSTANCENAME `
/INSTANCENAME=$INSTANCENAME `
/ISSVCSTARTUPTYPE=Automatic `
/QUIETSIMPLE `
/SAPWD=$SAPASS `
/SECURITYMODE=SQL `
/SQLSVCSTARTUPTYPE=Automatic `
/SQLSYSADMINACCOUNTS="bac\Domain Admins" "bac\DB Admins" `
/SQMREPORTING=False `
/TCPENABLED=1 `
/UpdateEnabled=1 `
/UpdateSource=MU
#Set Memory on Instance
import-module SQLPS -DisableNameChecking
Invoke-Sqlcmd -ServerInstance .\$INSTANCENAME -Username sa -Password $SAPASS -Query "EXEC sys.sp_configure 'show advanced options', 1"
Invoke-Sqlcmd -ServerInstance .\$INSTANCENAME -Username sa -Password $SAPASS -Query "RECONFIGURE"
Invoke-Sqlcmd -ServerInstance .\$INSTANCENAME -Username sa -Password $SAPASS -Query "EXEC sys.sp_configure 'max server memory (MB)', $InstMem"
Invoke-Sqlcmd -ServerInstance .\$INSTANCENAME -Username sa -Password $SAPASS -Query "EXEC sys.sp_configure 'show advanced options', 0"
Invoke-Sqlcmd -ServerInstance .\$INSTANCENAME -Username sa -Password $SAPASS -Query "RECONFIGURE"
}
从远程机器(如跳转主机)运行时,出现以下错误:
SQL Server 2016 transmits information about your installation experience, as well as other usage and performance data, to Microsoft to help improve
the product. To learn more about SQL Server 2016 data processing and privacy controls, please see the Privacy Statement.
The following error occurred:
The specified value for setting 'SAPWD' is invalid. The expected value type is SqlSecureString.
Error result: -2068578303
Result facility code: 1204
Result error code: 1
Please review the summary.txt log for further details
Microsoft (R) SQL Server 2016 13.00.1601.05
Copyright (c) 2016 Microsoft Corporation. All rights reserved.
Could not load file or assembly 'Microsoft.SqlServer.ConnectionInfo, Version=13.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of
its dependencies. The system cannot find the file specified.
+ CategoryInfo : NotSpecified: (:) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerShell.Commands.ImportModuleCommand
+ PSComputerName : DB12345
解决方案
您的问题帖子中几乎没有错误。其中之一是由于缺少 SMO(SQL 共享管理对象)而出现的:
Could not load file or assembly 'Microsoft.SqlServer.ConnectionInfo, Version=13.0.0.0
它可以从 SQL Server 功能包页面下载
如果安装没有帮助,请查看此线程: 无法加载文件或程序集 microsoft.sqlserver.sqlclrprovider 13.100.0.0
有一个相关的 ms 连接项的参考...
2019-02-09 更新:
/QUIETSIMPLE
指定安装程序运行并通过 UI 显示进度,但不接受任何输入或显示任何错误消息。
/QUIET
指定安装程序在没有任何用户界面的安静模式下运行。这用于无人值守的安装。/Q 参数覆盖 /QS 参数的输入。
/QUIETSIMPLE
由于通过 Invoke-Command进行/QUIET
远程执行对 QUIETSIMPLE 带来的交互性不满意,因此要更改 Setup.exe 参数
推荐阅读
- typescript - Typescript readonly到处切换?(功能参数)
- java - java sqlQuery字符串构建器中的循环模型getter参数
- java - java chrono 年份之间的单位差异
- android - 将 android:text 属性添加到任何 xml 布局文件中的任何元素时,Android Studio 会关闭
- javascript - 此代码正在工作,但在工作后为什么此代码显示错误
- python - 如何为不同的常数值运行相同的积分?
- java - 如何在oracle的TIMESTAMPTZ中存储java的ZonedDateTime?
- python - Python:能够使用 chrome 读取 rss url,但无法使用 python 读取
- scheme - 调试接受字符串的方案函数
- go - Gomock 不能使用类型 map[string]*mockFoo 作为 map[string]foo