Hi
As a part of a larger automation with PowerShell, I would like to install a SQL Express 2022 instance on a remote server.
I have this vars:
#variables for sql instance
$SQLServer = "SQL01"
$SQLInstanceName = -join ("T_","$TenantID")
$SQLInstanceFolder = -join ("D:\Instances\T_","$TenantID")
I have this function:
function New-SQLServerInstance {
param ($TenantID, $Server, $SQLInstanceFolder, $SQLInstanceName)
Write-Host ""
Write-Host "Die Installation der SQL Server 2022 Instanz für den Tenant $TenantID wird auf dem Server $Server gestartet. Dies dauert ein paar Minuten."
Invoke-Command -ComputerName $Server{
# Install SQL Instance
D:\SQL2022\Express_ENU\SETUP.EXE `
/SKIPRULES=RebootRequiredCheck `
/ACTION=Install `
/ERRORREPORTING=False `
/FEATURES="SQLEngine" `
/IACCEPTSQLSERVERLICENSETERMS=True `
/SUPPRESSPRIVACYSTATEMENTNOTICE=True `
/INSTANCEDIR=$SQLInstanceFolder `
/INSTANCEID=$SQLInstanceName `
/INSTANCENAME=$SQLInstanceName `
/SQLSYSADMINACCOUNTS="$GRP_DB" `
/QUIET `
/TCPENABLED=1 `
/UpdateEnabled=0 `
/UpdateSource=MU
}
}
The SQL Server installation starts but aborts a few seconds later with en error. If I have a look at the summary.txt (sql server install log) I get the error: "Exit message: The object state property 'this.InstanceId' is null/empty."
The corresponding fields are empty:
INSTANCEDIR:
INSTANCEID:
INSTANCENAME:
So basically I have a problem with handing over those arguments. I tried different things with " and ' or without. Doesn't work. The arguments without variables are passed to the sql installer.
Anybody knows how I need to do this?
Thanks and greetings
Matt