dataplat / dbatools

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

Update-DbaInstance can not use secure PS Remoting #9368

Open fm-knopfler opened 1 month ago

fm-knopfler commented 1 month ago

Verified issue does not already exist?

I have searched and found no existing issue

What error did you receive?

New-PSSession : [db01.internal.local] Connecting to remote server db01.internal.local failed with the following error message : WinRM cannot complete the operation. Verify that the specified computer name is valid, that the computer is accessible over the network, and that a firewall exception for the WinRM service is enabled and allows access from this computer. By default, the WinRM firewall exception for public profiles limits access to remote computers within the same local subnet. For more information, see the about_Remote_Troubleshooting Help topic.

Steps to Reproduce

# before executing, configure the remote machine to only accept encrypted WinRM connections using default port 5986
$cred = Get-Credential "internal.local\sqlAdmin"
Update-DbaInstance -ComputerName "db01.internal.local" -Credential $cred -Path '\\fs01.internal.local\SQL2022_Patch\CU13' 
# you get the same output when executing this (it works when using switch parameter -UseSSL)
$session = New-PSSession -ComputerName "db01.internal.local"  -Credential $cred

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

2.1.16

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.5576                                                                          
PSEdition                      Desktop                                                                                 
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                 
BuildVersion                   10.0.17763.5576                                                                         
CLRVersion                     4.0.30319.42000                                                                         
WSManStackVersion              3.0                                                                                     
PSRemotingProtocolVersion      2.3                                                                                     
SerializationVersion           1.1.0.1

SQL Server Edition and Build number

Microsoft SQL Server 2022 (RTM-CU12-GDR) (KB5036343) - 16.0.4120.1 (X64) Mar 18 2024 12:02:14 Copyright (C) 2022 Microsoft Corporation Standard Edition (64-bit) on Windows Server 2022 Standard 10.0 <X64> (Build 20348: ) (Hypervisor)

.NET Framework Version

PSChildName Version
----------- -------
Client      4.7.03190
Full        4.7.03190
Client      4.0.0.0
andreasjordan commented 3 weeks ago

@FriedrichWeinmann Can you help here? Wouldn't it be best to have the same kind of feature for WinRM sessions like for SQL sessions opened with Connect-DbaInstance? Like having a dedicated command to open a WinRM session with a lot of parameters and be able to pass that to commands that need to use WinRM?