dataplat / dbatools

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

Get-DbaStartupParameter does not honor -Simple parameter #9464

Closed hotsauceror closed 1 month ago

hotsauceror commented 1 month ago

Verified issue does not already exist?

I have searched and found no existing issue

What error did you receive?

$ get-dbastartupparameter -sqlinstance REDACTED -credential $t1 -simple                                                                                                                                                     

ComputerName         : REDACTED
InstanceName         :
SqlInstance          :
MasterData           : f:\sql\bin\mssql\MSSQL15.MSSQLSERVER\MSSQL\Data\master.mdf
MasterLog            : f:\sql\bin\mssql\MSSQL15.MSSQLSERVER\MSSQL\Data\\mastlog.ldf
ErrorLog             : f:\sql\bin\mssql\MSSQL15.MSSQLSERVER\MSSQL\Log\ERRORLOG
TraceFlags           : {4618, 4610, 9567}
DebugFlags           : None
CommandPromptStart   : False
MinimalStart         : False
MemoryToReserve      : 0
SingleUser           : False
SingleUserName       :
NoLoggingToWinEvents : False
StartAsNamedInstance : False
DisableMonitoring    : False
IncreasedExtents     : False
ParameterString      : -df:\sql\bin\mssql\MSSQL15.MSSQLSERVER\MSSQL\Data\master.mdf;-ef:\sql\bin\mssql\MSSQL15.MSSQLSERVER\MSSQL\Log\ERRORLOG;-lf:\sql\bin\mssql\MSSQL15.MSSQLSERVER\MSSQL\Data\\mastlog.ldf;-T4618;-T4610;-T9567

$ get-dbastartupparameter -sqlinstance REDACTED -credential $t1 -Simple:$true                                                                                                                                               

ComputerName         : REDACTED
InstanceName         :
SqlInstance          :
MasterData           : f:\sql\bin\mssql\MSSQL15.MSSQLSERVER\MSSQL\Data\master.mdf
MasterLog            : f:\sql\bin\mssql\MSSQL15.MSSQLSERVER\MSSQL\Data\\mastlog.ldf
ErrorLog             : f:\sql\bin\mssql\MSSQL15.MSSQLSERVER\MSSQL\Log\ERRORLOG
TraceFlags           : {4618, 4610, 9567}
DebugFlags           : None
CommandPromptStart   : False
MinimalStart         : False
MemoryToReserve      : 0
SingleUser           : False
SingleUserName       :
NoLoggingToWinEvents : False
StartAsNamedInstance : False
DisableMonitoring    : False
IncreasedExtents     : False
ParameterString      : -df:\sql\bin\mssql\MSSQL15.MSSQLSERVER\MSSQL\Data\master.mdf;-ef:\sql\bin\mssql\MSSQL15.MSSQLSERVER\MSSQL\Log\ERRORLOG;-lf:\sql\bin\mssql\MSSQL15.MSSQLSERVER\MSSQL\Data\\mastlog.ldf;-T4618;-T4610;-T9567

Steps to Reproduce

get-dbastartupparameter -sqlinstance REDACTED -credential $cred -simple
get-dbastartupparameter -sqlinstance REDACTED -credential $cred -simple:$true

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

2.1.14

Other details or mentions

Expected behavior: -simple switch returns only these attributes:

if ($Simple -eq $true) {
     [PSCustomObject]@{
                            ComputerName    = $computerName
                            InstanceName    = $instanceName
                            SqlInstance     = $ogInstance
                            MasterData      = $masterData.TrimStart('-d')
                            MasterLog       = $masterLog.TrimStart('-l')
                            ErrorLog        = $errorLog.TrimStart('-e')
                            TraceFlags      = $traceFlags
                            DebugFlags      = $debugFlags
                            ParameterString = $wmisvc.StartupParameters
                        }

Observed behavior: -simple switch returns all of the attributes

                        [PSCustomObject]@{
                            ComputerName         = $computerName
                            InstanceName         = $instanceName
                            SqlInstance          = $ogInstance
                            MasterData           = $masterData -replace '^-[dD]', ''
                            MasterLog            = $masterLog -replace '^-[lL]', ''
                            ErrorLog             = $errorLog -replace '^-[eE]', ''
                            TraceFlags           = $traceFlags
                            DebugFlags           = $debugFlags
                            CommandPromptStart   = $commandPrompt
                            MinimalStart         = $minimalStart
                            MemoryToReserve      = $memoryToReserve
                            SingleUser           = $singleUser
                            SingleUserName       = $singleUserDetails
                            NoLoggingToWinEvents = $noEventLogs
                            StartAsNamedInstance = $instanceStart
                            DisableMonitoring    = $disableMonitoring
                            IncreasedExtents     = $increasedExtents
                            ParameterString      = $wmisvc.StartupParameters

What PowerShell host was used when producing this error

PowerShell Core (pwsh.exe), Windows PowerShell (powershell.exe)

PowerShell Host Version

5.1.19041.4780 7.4.2

SQL Server Edition and Build number

Microsoft SQL Server 2019 (RTM) - 15.0.2000.5 (X64) Sep 24 2019 13:48:23 Copyright (C) 2019 Microsoft Corporation Enterprise Edition: Core-based Licensing (64-bit) on Windows Server 2022 Datacenter 10.0 (Build 20348: ) (Hypervisor)

.NET Framework Version

.NET Framework 4.8.9261.0

hotsauceror commented 1 month ago

I was wrong, there is an existing issue #9196. Withdrawing.