安装和配置SQL脚本问题


PowerShell交流中心安装和配置SQL脚本问题
0
hx0378 asked 10 年 ago

找了一段脚本,思路是加载iso文件,然后运行安装SQL,然后再通过ConfigurationFile.ini文件,进行SQL配置。

问题是脚本运行后,虽然成功的加载了iso文件,也能找到ini文件,但就是没有运行安装,没有提示任何错误信息,也通过断点运行调试,也没有找到问题,希望这里能得到大家的帮助。谢谢。

脚本如下:

SetScript =
{
# mount the iso
$setupDriveLetter = (Mount-DiskImage -ImagePath c:\temp\SQLServer.iso -PassThru | Get-Volume).DriveLetter + ":"
if ($setupDriveLetter -eq $null) {
throw "Could not mount SQL install iso"
}
Write-Verbose "Drive letter for iso is: $setupDriveLetter"

# run the installer using the ini file
$cmd = "$setupDriveLetter\Setup.exe /ConfigurationFile=c:\temp\ConfigurationFile.ini /SQLSVCPASSWORD=P2ssw0rd /AGTSVCPASSWORD=P2ssw0rd /SAPWD=P2ssw0rd"
Write-Verbose "Running SQL Install - check %programfiles%\Microsoft SQL Server\120\Setup Bootstrap\Log\ for logs..."
Invoke-Expression $cmd | Write-Verbose
}

 

Mooser Lee 管理员 replied 10 年 ago

你原来这个脚本可能需要加上$cmd = “& $setupDriveLetter\Setup.exe“

1 Answers
1
Best Answer
Mooser Lee 管理员 answered 10 年 ago

不好意思,最近工作忙,这么晚回复您:
试试我的更改:

SetScript =
{
# mount the iso
$setupDriveLetter = (Mount-DiskImage -ImagePath c:\temp\SQLServer.iso -PassThru | Get-Volume).DriveLetter + “:”
if ($setupDriveLetter -eq $null) {
throw “Could not mount SQL install iso”
}
Write-Verbose “Drive letter for iso is: $setupDriveLetter”

# run the installer using the ini file
$setupExe= "$setupDriveLetter\Setup.exe"
$setupArgs= "/ConfigurationFile=c:\temp\ConfigurationFile.ini /SQLSVCPASSWORD=P2ssw0rd /AGTSVCPASSWORD=P2ssw0rd /SAPWD=P2ssw0rd"
Write-Verbose “Running SQL Install – check %programfiles%\Microsoft SQL Server\120\Setup Bootstrap\Log\ for logs…”
Start-Process -FilePath $setupExe -ArgumentList $setupArgs
}