Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restart-DbaService not working well with Credentials #9552

Open
dokier opened this issue Nov 21, 2024 · 0 comments
Open

Restart-DbaService not working well with Credentials #9552

dokier opened this issue Nov 21, 2024 · 0 comments
Labels
bugs life triage required New issue that has not been reviewed by maintainers

Comments

@dokier
Copy link

dokier commented Nov 21, 2024

Verified issue does not already exist?

I have searched and found no existing issue

What error did you receive?

Restart-DbaService does not work well when passing a Credential.

WARNING: [12:44:52][Get-DbaCmObject] [servername.domain.com] Invalid connection credentials

Restart-DbaService calls Update-ServiceStatus but it's not passing a credential on line 151 and 157. Even if you add a Credential here, Update-ServiceStatus then uses Invoke-Parallel calling a script block called "$svcControlBlock" but there is no credential being passed there either.

if ($processArray) {
            if ($PSCmdlet.ShouldProcess("$ProcessArray", "Restarting Service")) {
                $services = Update-ServiceStatus -InputObject $processArray -Action 'stop' -Timeout $Timeout -EnableException $EnableException
                foreach ($service in ($services | Where-Object { $_.Status -eq 'Failed' })) {
                    $service
                }
                $services = $services | Where-Object { $_.Status -eq 'Successful' }
                if ($services) {
                    Update-ServiceStatus -InputObject $services -Action 'restart' -Timeout $Timeout -EnableException $EnableException
                }
            }
        } else {
            Stop-Function -EnableException $EnableException -Message "No SQL Server services found with current parameters."
        }

Steps to Reproduce

# provide your command(s) executed pertaining to dbatools
# please include variable values (redacted or fake if needed) for reference

Log into your client computer with an account without access to the remote server (this step is very important). Then create a credential variable with an account with access to the remote server.
$cred = Get-Credential # Enter a credential to access to the remote server"
Restart-DbaService -ComputerName computer1 -Credential $cred

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

2.1.28

Other details or mentions

No response

What PowerShell host was used when producing this error

Windows PowerShell (powershell.exe)

PowerShell Host Version

Name Value


PSVersion 5.1.17763.6414
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.6414
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

SQL Server Edition and Build number

Not Important here

.NET Framework Version

.NET Framework 4.8.4762.0

@dokier dokier added bugs life triage required New issue that has not been reviewed by maintainers labels Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugs life triage required New issue that has not been reviewed by maintainers
Projects
None yet
Development

No branches or pull requests

1 participant