-
-
Notifications
You must be signed in to change notification settings - Fork 808
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
Set-DbaNetworkCertificate - Support localhost and use it as default for SqlInstance #9098
Conversation
Follows other functions in the project and sets the default value to localhost, as promised in the parameter description.
build error for appveyor was: Build execution time has reached the maximum allowed time for your plan (60 minutes). how to proceed? |
There is nothing you can do... But there are other changes needed, as after your change, the connection to localhost is still a "remote" connection and fails if WinRM is not set up. We need to test for localhost and then run the code localy and not remote. Will come back to you to help with this later. |
Refactored 'Set-DBANetworkCertificate' by removing the Resolve-Section, as it now occurs in 'Invoke-ManagedComputerCommand' as well. This ensures the command can be run locally. Simplified 'Invoke-ManagedComputerCommand' by replacing the nested try/catch blocks with a loop for better readability and maintainability.
@andreasjordan, as discussed I've added another commit to this PR. Refactored 'Set-DBANetworkCertificate' by removing the Resolve-Section, as it now occurs in 'Invoke-ManagedComputerCommand' as well. This ensures the command can be run locally. Simplified 'Invoke-ManagedComputerCommand' by replacing the nested try/catch blocks with a loop for better readability and maintainability. |
Thank you, @HCRitter ! I'll let Andreas take care of this one, as there are a lot of changes. Happy to merge once approvals and tests pass. |
Improved the specificity of verbose messages for remote connections with specific versions in Invoke-Command2.
Is this ready, @andreasjordan ? 🙏🏼 |
No, not yet. Maybe I can test that later today. Will give feedback as soon as possible. |
thanks, friend! 🍻 |
|
||
$computerName = $instance.ComputerName | ||
$instanceName = $instance.instancename | ||
|
||
try { | ||
$sqlwmi = Invoke-ManagedComputerCommand -ComputerName $resolved.FQDN -ScriptBlock { $wmi.Services } -Credential $Credential -ErrorAction Stop | Where-Object DisplayName -eq "SQL Server ($instanceName)" | ||
# removed: Resolve-DbaNetworkName command as it is used in the Invoke-ManagedComputerCommand anyway | ||
$sqlwmi = Invoke-ManagedComputerCommand -ComputerName $computerName -ScriptBlock { $wmi.Services } -Credential $Credential -ErrorAction Stop | Where-Object DisplayName -eq "SQL Server ($instanceName)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change from $resolved.FQDN
to $computerName
has to be applied to new lines 232 and 239 as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@HCRitter Do you have time to update the pull request?
I tested this with stopped WinRM service and restarting the service with |
The underlying CM system was intended to just work locally, even with disabled WinRM (it automatically switches to CIM/DCOM for localhost). There are problems with that though, as I just tested myself. To make this work, we need to ...
Looking into it right now. All the changes needed will be within the CM code and the |
Thanks Fred. If I can help, just let me know. |
Just submitted part one: #9107 Pretty sure I know how I'm fixing part two (Invoke-CimMethod):
To make this work well, we'd need to update & ship the library first, then wait for the next release of the main dbatools to also update the commands afterwards, in order to avoid breaking the tests. |
Stage 2 is implemented and pending as PR on the library side: Again, not a prerequisite for this PR, but just to keep everybody in the loop. :) |
Thank you, @FriedrichWeinmann ! Will merge your PRs shortly. |
Follows other functions in the project and sets the default value to localhost, as promised in the parameter description.
Please read -- recent changes to our repo
On November 10, 2022, we removed some bloat from our repository (for the second and final time). This change requires that all contributors reclone or refork their repo.
PRs from repos that have not been recently reforked or recloned will be closed and @potatoqualitee will cherry-pick your commits and open a new PR with your changes.
Type of Change
.\tests\manual.pester.ps1
)Purpose
fixes issue: #9057
Approach
Follows other functions in the project and sets the default value to localhost, as promised in the parameter description.