Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the relationship between gwmi and Get-WmiObject

Tags:

powershell

After reading around, I'm confused about the relationship between these. I don't believe gwmi is a pure alias for Get-WmiObject, as they seem to share similar but not identical syntax in the examples I've seen.

Interestingly enough, when I google "gwmi" on its own, all the top references immediately refer back to Get-WmiObject but don't seem to reference gwmi itself.

like image 294
dave_the_dev Avatar asked Jul 16 '15 00:07

dave_the_dev


People also ask

What is difference between Get-CimInstance and get WMI object?

Get-WmiObject is formatting its output as a list, while Get-CimInstance is displaying its output in table form. The actual information that is being displayed is mostly the same. This isn't to say that there are no differences between the two cmdlets.

What does get-WmiObject do?

The Get-WmiObject cmdlet gets instances of WMI classes or information about the available WMI classes. To specify a remote computer, use the ComputerName parameter. If the List parameter is specified, the cmdlet gets information about the WMI classes that are available in a specified namespace.

What port does get-WmiObject use?

For a WMI connection to succeed, the remote computer must permit incoming network traffic on TCP ports 135, 445, and additional dynamically assigned ports between 1024 to 1034.

What is get-CimInstance?

The Get-CimInstance cmdlet gets the CIM instances of a class from a CIM server. You can specify either the class name or a query for this cmdlet. This cmdlet returns one or more CIM instance objects representing a snapshot of the CIM instances present on the CIM server.


2 Answers

There is no fancy voodoo at work here. Aliases in PowerShell are a very simple mechanic that help with short hand coding. Unix aliases, on the other hand, are different and can include entire command calls (Which could possibly be a source of confusion?).

In all cases, there is nothing more that just what you see here from Get-Alias

PS C:\Users\Bagel> get-alias gwmi

CommandType     Name                                               ModuleName                                                      
-----------     ----                                               ----------                                                      
Alias           gwmi -> Get-WmiObject                                                                                              

If you have evidence to the contrary I am sure the community would love to see it!

like image 193
Matt Avatar answered Sep 25 '22 22:09

Matt


The authoritative reference you need to clear this up is about_Aliases:

An alias is an alternate name or nickname for a cmdlet or for a command element, such as a function, script, file, or executable file. You can use the alias instead of the command name in any Windows PowerShellcommands.

like image 28
alx9r Avatar answered Sep 28 '22 22:09

alx9r