Get-WmiObject Remote Computer: Inventory Computers Using PowerShell

How can I inventory remote computers using PowerShell? The answer is using Get-WmiObject on remote computer. This post provides you with a full tutorial. Keep reading if you’re interested.

Ellie

By Ellie / Updated on January 5, 2023

Share this: instagram reddit

How do I connect to WMI remotely?

Windows Management Instrumentation (WMI) is a management infrastructure built-in to Windows for querying management and operations data. It can be used to query local and remote computers for information like running processes, installed software, BIOS information, and much more.

The Get-WmiObject cmdlet gets instances of WMI classes or information about the available WMI classes.You can use the ComputerName parameter to specify a remote computer, so you can connect to WMI remotely.

How to use PowerShell Get-WMIObject on remote computer

Next, we’ll see how to use PowerShell Get-WmiObject on remote computer to inventory computer information.

If the Query parameter is specified, the cmdlet runs a WMI query language (WQL) statement. If the List parameter is specified, the cmdlet gets information about the WMI classes that are available in a specified namespace. The ComputerName parameter is used to specify computers. Let’s see some examples.

First, let’s test the WMI connection to the remote computer. The example shows below allowing you to test the WMI connection to the remote computer called PC1.

  • Get-WmiObject -query "SELECT * FROM Win32_OperatingSystem" -ComputerName PC1

Test WMI Connection

You can also enumerate the Network Shares list from a remote machine by using Powerahell’s WMI class Win32_Share. Here, FT is nothing but the Format-Table cmdlet, you can change it into FL to display result in list view.

  • Get-WMIObject -ComputerName "PC1" -Query "SELECT * FROM Win32_Share" | FL

Network Share List

You can use SQL Query like syntax to apply filter in Win32_Share class. The following Powershell script, filters and list only Network Share Folders (Not hidden shares) by adding filter Type=0.

  • Get-WMIObject -ComputerName "PC1" -Query "SELECT * FROM Win32_Share Where Type=0" | FT

Network Share Folder

More examples

Example 1: Gets services on theremote computer PC1:

  • Get-WmiObject -Class Win32_Service -ComputerName PC1

You can also Get the services on a remote computerusing Get-WmiObject remote computerCredential. The following example uses the Credential parameter. The value of the Credential parameter is a user account name. The user is prompted for a password.

  • Get-WmiObjectWin32_Service -Credential FABRIKAM\administrator -ComputerName Fabrikam

Example 2: Stop a service on theremote computer PC1:

  • (Get-WmiObject -Class Win32_Service -Filter "name='WinRM'" -ComputerName PC1).StopService()

Example 3: Get the BIOS on theremote computer PC1:

  • Get-WmiObject -Class Win32_Bios -ComputerName PC1| Format-List -Property *

Note

We should note you that Get-WmiObject cmdlet has been superseded by Get-CimInstancein PowerShell 3.0. For example, the following command displays each running process name along with its kernel time from largest to smallest:

  • Get-CimInstance -Class Win32_Process -ComputerName DC1 | Select-Object -Property Name,KernelModeTime | Sort-Object KernelModeTime -Descending

Get WmiObject

AnyViewer: GUI remote desktop solution for Windows

If you want a more direct way to querycomputer management and operations data, we strongly recommend AnyViewer, a free remote desktop program that allows you to remotely control a computer from another. It offers a graphical user interface to a remote computer, which is way direct and intuitive compared to PowerShell.

Download Freeware Win 11/10/8.1/8/7
Secure Download

Step 1. Download, install and launch AnyViewer on both computers.

Download AnyViewer

Step 2. Go to Log in, and then click Sign up. (If you already have signed up on its official website, you can log in directly.)

Log in AnyViewer

Step 3. Fill in the signup information.

Sign Up for AnyViewer

Step 4. Then you can see you successfully logged in to AnyViewer. Your device will automatically be assigned to the account you've logged in to.

Free Editions

Step 5. Log in to the same AnyViewer account on the two devices, then click One-click control to achieve unattended remote access.

Connect to My Devices

✍Note: If you upgrade your account to a Professional or Enterprise plan, then you’ll have more rights:

  • You can assign more devices to achieve unattended remote access.
  • More currently connected devices will be displayed, which is convenient for you to view more connection histories at any time.
  • You can connect to another computer in privacy mode, which means you can black the screen and block the mouse and keyboard of the remote computer, further protecting your privacy.

Step 6. After you’ve got full control of the remote computer, you can then open any program and manage it as if you’re using it actually.

AnyViewer Computer Management

The bottom line

This post provides you with a full tutorial on how to use PowerShell Get-WmiObject on remote computer to inventory computer information. If you want a more direct and intuitive way to querycomputer management and operations data, you are advised to use AnyViewer.