WMI has been there for more than 20 years, but many people are not familiar with it. Know it is very good very strong, but do not know where it comes from, how to work, what is the scope of use? Now I'm going to tell you about my understanding ...
WMI has a set of APIs. Whether we use VBScript, the PowerShell script, or the class library that uses C # to visit WMI is due to a set of APIs that WMI exposes out of the way. These APIs were installed when the system installed the WMI module, and through them we were able to get the classes we wanted.
WMI has a repository. Although most instance data for WMI is not stored in WMI, WMI does have a repository for class information provided by the provider, or as a blueprint or schema for a class.
WMI has a service. WMI is always able to respond to user access because it has a running Windows service named WinMgmt. Stop this service and all operations on WMI will not respond.
WMI is extensible. Everyone knows that WMI can do a lot of things, read local hard drive information, read user information for remote computers, read domain user information, and so on. Basically, what you can think of is the ability to get or change a resource's operations. Eat less and do much. Why is it so capable? This is based on the scalability of WMI. WMI operates on a resource not by its own method, but entirely by the provider it registers with.
WMI is one of the powerful tools that administrators have to do every day and is a scripting companion. Of course, a large system can be built on the WMI and WMI providers. Here are two examples of using WMI:
Example one:
This example uses VB script to check the physical memory of this computer:
Copy Code code as follows:
StrComputer = "."
Set wbemservices = Getobject ("winmgmts:\\" & StrComputer)
Set wbemObjectSet = wbemservices.instancesof ("Win32_LogicalMemoryConfiguration")
For each wbemobject in wbemObjectSet
WScript.Echo "Total Physical Memory (KB):" & Wbemobject.totalphysicalmemory
Next
Example two:
This example uses PowerShell to check the logical hard disk conditions on this computer:
Copy Code code as follows:
PS c:\users\v-lukez> Get-wmiobject-class Win32_LogicalDisk
Conclusion:
WMI is powerful and has been evolving, but it has been tepid because there are not many people to use. Hope that more people will be able to understand the pearl, see the potential.