I am trying to install SQL server 2016 on remote machine using PowerShell. below is my script. Can someone please help in identifying the issue.
# 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"
}
While running from remote machine like jump host i am getting below error:
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