Skip to content

Commit d5d9fd3

Browse files
Get-DbaStartupParameter: Fix multiple issues (#10208)
1 parent f3e4022 commit d5d9fd3

1 file changed

Lines changed: 8 additions & 13 deletions

File tree

public/Get-DbaStartupParameter.ps1

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,14 @@ function Get-DbaStartupParameter {
9494
$instanceName = $instance.InstanceName
9595
$ogInstance = $instance.FullSmoName
9696

97-
$computerName = (Resolve-DbaNetworkName -ComputerName $computerName).FullComputerName
98-
99-
100-
if ($instanceName.Length -eq 0) { $instanceName = "MSSQLSERVER" }
101-
102-
$displayName = "SQL Server ($instanceName)"
103-
10497
$scriptBlock = {
10598
$computerName = $args[0]
106-
$displayName = $args[1]
107-
$Simple = $args[2]
99+
$instanceName = $args[1]
100+
$ogInstance = $args[2]
101+
$Simple = $args[3]
108102

109-
$wmisvc = $wmi.Services | Where-Object DisplayName -eq $displayName
103+
$wmisvc = $wmi.Services | Where-Object DisplayName -eq "SQL Server ($instanceName)"
104+
if (-not $wmisvc) { return }
110105

111106
$params = $wmisvc.StartupParameters -split ';'
112107

@@ -208,10 +203,10 @@ function Get-DbaStartupParameter {
208203

209204
# This command is in the internal function
210205
# It's sorta like Invoke-Command.
211-
if ($credential) {
212-
Invoke-ManagedComputerCommand -Server $computerName -Credential $credential -ScriptBlock $scriptBlock -ArgumentList $computerName, $displayName, $Simple
206+
if ($Credential) {
207+
Invoke-ManagedComputerCommand -Server $computerName -Credential $Credential -ScriptBlock $scriptBlock -ArgumentList $computerName, $instanceName, $ogInstance, $Simple
213208
} else {
214-
Invoke-ManagedComputerCommand -Server $computerName -ScriptBlock $scriptBlock -ArgumentList $computerName, $displayName, $Simple
209+
Invoke-ManagedComputerCommand -Server $computerName -ScriptBlock $scriptBlock -ArgumentList $computerName, $instanceName, $ogInstance, $Simple
215210
}
216211
} catch {
217212
Stop-Function -Message "$instance failed." -ErrorRecord $_ -Continue -Target $instance

0 commit comments

Comments
 (0)