WinRM cannot process the request.

CharlieLor 566 Reputation points
2023-03-27T17:47:18.53+00:00

I have local admin right on all remote servers that I'm trying to query the expiring certificate. I'm also able to query this same remote server for their Sql Server version by using Invoke-Sqlcmd -query "select @@version" -ServerInstance $dbName however, for querying the cert with Invoke-Command I got the following error.

[MyServer.SERVERS.myComp.com] Connecting to remote server 
MyServer.SERVERS.myComp.com failed with the following error message : WinRM cannot process the request. The following error occurred while using Kerberos 
authentication: Cannot find the computer 
MyServer.SERVERS.myComp.com. Verify that the computer exists on the network and that the name provided is spelled correctly. For more information, see the 
about_Remote_Troubleshooting Help topic.
    + CategoryInfo          : OpenError: (MyServer.SERVERS.myComp.com:String) [], PSRemotingTransportException
    + FullyQualifiedErrorId : NetworkPathNotFound,PSSessionStateBroken

This the code.

$servers = @("MyServer.SERVERS.myComp.com")

##### Loop through all servers in the server array #####
foreach($server in $servers) {


   $expiredCert = Invoke-Command -ComputerName $server -ScriptBlock {Get-ChildItem -Path Cert:\localmachine\my | ?{$_.NotAfter -lt (get-date).AddDays(30)} | Select Thumbprint,FriendlyName,NotAfter, NotBefore}

}

if ($expiredCert){
    Write-Output $expiredCert
}

On the remote server, winRM is enabled and running.User's image

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. CharlieLor 566 Reputation points
    2023-03-27T19:12:13.4233333+00:00

    Okay, I think I figured it out. Instead of using the FQDN, I just used the name of the server and it seemed to work for now.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.