What is WMI in the Getting Started tutorial? _powershell

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.