Windows Remote Management (WinRM) is the Microsoft implementation of WS-Management Protocol, a standard Simple Object Access Protocol (SOAP)-based, firewall-friendly protocol that allows hardware and operating systems, from different vendors, to interoperate. The WS-Management protocol specification provides a common way for systems to access and exchange management information across an IT infrastructure. Please refer to these related guides: How to fix the following error occurred while using Kerberos authentication, cannot find the computer, and how to configure a remote server (windows) to Support Ansible. In this guide, you will learn how to fix the following error “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”.
WinRM is enabled by default on all Windows Server operating systems since Windows Server 2012 and above, but disabled on all client operating systems like Windows 10 and Windows 11 at the time of writing this guide. Here is a guide on how to fix Get-CimInstance Access PermissionDenied: (root\cimv2:Win32_OperatingSystem String) [Get-CimInstance], CimException on Windows, How to determine Windows PowerShell version and to see if WinRM is running via Test-WSMan, and how to add servers to the Trusted Hosts list via PowerShell and command Prompt for the WinRM client.
As mentioned in the first paragraph, WinRM establishes a session with a remote computer through the SOAP-based WS-Management protocol rather than a connection through DCOM, as WMI does. The CimInstance cmdlets interact with Common Information Model (CIM) Servers like the Windows Management Instrumentation (WMI) service. Data returned to the WS-Management protocol are formatted in XML rather than in objects. As you are aware, the
Get-WmiObject cmdlet has been superseded with the
Get-CimInstance cmdlets as discussed in this guide “How to get a list of installed applications using PowerShell in Windows“, and because of some comments on this blog post. This birthed this guide. Below are some of the errors you might encounter while performing this operation.
WinRM is automatically installed with all currently-supported versions of the Windows operating system, but needs o be confiured on client PCs.
When prompted with the following error above, the first step to resolve this issue is to verify if WinRM is running on the device. As you can see in the image below, this is not the case. This is because, for Windows Remote Management (WinRM) scripts to run, and for the Winrm command-line tool to perform data operations, Windows Remote Management (WinRM) has to be configured. Therefore, we will have to configure WinRM in order to be able to receive requests.
Configure WinRM with default settings
Type winrm quickconfig at a command prompt. As you can see, I am running PowerShell as an Administrator. This is because I am not running under the local computer Administrator account.
Kindly pay attention to the prompts as shown below. When the tool displays Make these changes [y/n]? Kindly type
y to proceed.
As you can see below, we have successfully configured WInRM, and it is running.
Now that we are done configuring WinRM if you do not have Administrative rights to connect to the remote device, the following error below will be prompted.
To resolve this issue, you will need to grant the necessary rights locally or via a security group. Here is a related guide on allowing RDP access for non administrators: Add User to Remote Desktop Users Group in Active Directory. Since I am part of a Security Group that has Administrative privileges on this device, I will have to run the Command Prompt as a different user in order to be able to perform my task without further errors.
C:\Users\yourname\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\System Tools
To do this, kindly access the Command Prompt via the File Explorer and right click on it. Then select “Run as a different user”.
You will be required to enter your Username and Password. Kindly enter the credential that has administrative rights on the device you wish to manage remotely.
Remotely Query the List of Installed Apps
Proceed and perform any action you wish on the remote device. Since I would like to query the list of installed applications on that device, I will be running the command below. Please replace “TechPC!” with your device name.
PS C:\WINDOWS\system32> Get-CimInstance -class Win32_Product -Computer techPC1
To query remote devices, kindly run the command below. In the past, we have always achieved this with the Get-Wmi-Object. But has been superseded with the CimInstance, below is the new command to use. You can also query the list of installed apps by Vendor as you wish.
PS C:\Windows> Get-CimInstance -Class Win32_Product -Computer TechdaPC2 | where vendor -eq 'Microsoft Corporation' | select Name, Version
PS C:\Windows> Get-CimInstance -Class Win32_Product -Computer TechdaPC2
I hope you found this blog post helpful. If you have any questions, please let me know in the comment session.