PowerShell 7.3 - implementing Using Invoke-Command for Remote Execution on Multiple Hosts with Domain Credentials
I recently switched to I'm performance testing and I am trying to remotely execute a PowerShell script on multiple hosts using `Invoke-Command`, but I'm running into issues with domain credentials. Specifically, I want to run a script that retrieves some performance metrics from several servers in my domain. Hereโs a simplified version of what my code looks like: ```powershell $servers = @('Server1', 'Server2', 'Server3') $credential = Get-Credential -Message 'Enter your domain credentials' $scriptBlock = { Get-CimInstance -ClassName Win32_Processor | Select-Object Name, LoadPercentage } Invoke-Command -ComputerName $servers -Credential $credential -ScriptBlock $scriptBlock ``` When I run this, I get an behavior message like: ``` Enter-PSSession : [Server1] Connecting to remote server Server1 failed with the following behavior message : The user name or password is incorrect. ``` Iโve verified that the credentials Iโm entering are correct, and that the accounts have permission to run scripts on the target servers. I also ensured that WinRM is configured properly on all servers by running `winrm quickconfig`. After checking these, I even tried running it without the `-Credential` parameter, but that resulted in: ``` Invoke-Command : The WinRM client want to process the request. ``` I also added the servers to the trusted hosts list using `Set-Item WSMan:\localhost\Client\TrustedHosts -Value 'Server1,Server2,Server3'`, but that didnโt help either. I suspect it might be related to how the credentials are being handled when connecting to remote machines, especially since some of these servers are in a different organizational unit. Has anyone encountered similar issues or have suggestions on how to properly execute remote commands with domain credentials in PowerShell 7.3? This issue appeared after updating to Powershell latest. I appreciate any insights! The stack includes Powershell and several other technologies. Thanks for your help in advance!