dataplat / dbatools

🚀 SQL Server automation and instance migrations have never been safer, faster or freer
https://dbatools.io
MIT License
2.39k stars 788 forks source link

Install-DbaInstance: Can't install instance to drive root #9223

Closed fm-knopfler closed 4 months ago

fm-knopfler commented 5 months ago

Verified issue does not already exist?

I have searched and found no existing issue

What error did you receive?

writeErrorStream      : True
PSMessageDetails      : 
Exception             : System.Exception: Installation failed with exit code -2061893624. Expand 'ExitMessage' and 'Log' property to find more details.
TargetObject          : 
CategoryInfo          : NotSpecified: (:) [Write-Error], Exception
FullyQualifiedErrorId : dbatools_Invoke-DbaAdvancedInstall,Stop-Function
ErrorDetails          : Installation failed with exit code -2061893624. Expand 'ExitMessage' and 'Log' property to find more details.
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at Stop-Function, <No file>: line 97916
                        at Invoke-DbaAdvancedInstall, <No file>: line 45306
                        at <ScriptBlock>, <No file>: line 44324
                        at Install-DbaInstance<Process>, <No file>: line 44328
                        at <ScriptBlock>, <No file>: line 27
PipelineIterationInfo : {0, 1}

Steps to Reproduce

Import-Module dbatools -RequiredVersion "2.1.6"

$svcCred = Get-Credential

$installparams = @{
    "Version" = 2022
    "Path" = "D:"
    "InstanceName" = "SQL22_S01"
    "Feature" = "Engine"
    "InstancePath" = "E:\"
    "DataPath" = "E:\SQL22_S01\MSSQL\Data"
    "LogPath" = "E:\SQL22_S01\MSSQL\Log"
    "TempPath" = "E:\SQL22_S01\MSSQL\TempDB"
    "BackupPath" = "E:\Backup"
    "AdminAccount" = "administrator"
    "EngineCredential" = $svcCred
    "AgentCredential" = $svcCred
    "AuthenticationMode" = "Mixed"
    "PerformVolumeMaintenanceTasks" = $true
    "Verbose" = $true
    "Configuration" = @{
         "SQLMINMEMORY" = 2048
         "SQLMAXMEMORY" = 2048
    }
    "SaveConfiguration" = "C:\SQL2022.ini"
    "SqlCollation" = "Latin1_General_CI_AS"
    "Port" = "50001"
    "Confirm" = $false
}

Install-DbaInstance @installparams

Please confirm that you are running the most recent version of dbatools

2.1.6

Other details or mentions

This error occurs, when setting "InstancePath" = "E:\" or the root folder of any drive in Windows. The issue is similar to #8627, but still occurs using the latest version of dbatools.

The following values lead to the same result for me:

Using a non-root folder like "E:\Inst01" worked as excpected.

Installation Config and Summary:

SQL2022.ini.txt Summary.txt

Note the following entry ate line 97 in summary.txt: INSTANCEDIR: E:"

What PowerShell host was used when producing this error

Windows PowerShell ISE (powershell_ise.exe)

PowerShell Host Version

Name                           Value                                                                                                                                  
----                           -----                                                                                                                                  
PSVersion                      5.1.20348.2227                                                                                                                         
PSEdition                      Desktop                                                                                                                                
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                
BuildVersion                   10.0.20348.2227                                                                                                                        
CLRVersion                     4.0.30319.42000                                                                                                                        
WSManStackVersion              3.0                                                                                                                                    
PSRemotingProtocolVersion      2.3                                                                                                                                    
SerializationVersion           1.1.0.1                                                                                                                                

SQL Server Edition and Build number

Sql Server is not yet installed. A Sql Server 2022 installation image was used. Using Sql Server 2019, the result is the same.

.NET Framework Version

PSChildName Version
----------- -------
Client      4.8.04161
Full        4.8.04161
Client      4.0.0.0
StanDaMan0505 commented 5 months ago

I experience exactly the same.

andreasjordan commented 4 months ago

Can you try to use "E:\\"? I think the problem is inside of the setup.exe with the \" at the end of the parameter.

andreasjordan commented 4 months ago

I could just successfully install a 2022 version into C: using a dubble backslash. I will provide a fix for that.

fm-knopfler commented 4 months ago

I can confirm, that the installation works when using "E:\\" for InstancePath (using version 2.1.10). It didn't matter if paths for parameters "DataPath", "LogPath", "TempPath", "BackupPath" started with "E:\\" or "E:\".

Import-Module dbatools -RequiredVersion "2.1.10"

$svcCred = Get-Credential

$installparams = @{
    "Version" = 2022
    "Path" = "D:"
    "InstanceName" = "SQL22_S01"
    "Feature" = "Engine"
    "InstancePath" = "E:\\"
    "DataPath" = "E:\SQL22_S01\MSSQL\Data"
    "LogPath" = "E:\SQL22_S01\MSSQL\Log"
    "TempPath" = "E:\SQL22_S01\MSSQL\TempDB"
    "BackupPath" = "E:\Backup"
    "AdminAccount" = "administrator"
    "EngineCredential" = $svcCred
    "AgentCredential" = $svcCred
    "AuthenticationMode" = "Mixed"
    "PerformVolumeMaintenanceTasks" = $true
    "Verbose" = $true
    "Configuration" = @{
         "SQLMINMEMORY" = 2048
         "SQLMAXMEMORY" = 2048
    }
    "SaveConfiguration" = "C:\SQL2022.ini"
    "SqlCollation" = "Latin1_General_CI_AS"
    "Port" = "50001"
    "Confirm" = $false
}

Install-DbaInstance @installparams
andreasjordan commented 4 months ago

Will open a PR with a fix later today.