Windows PowerShell is a command-line shell and scripting environment that enables command line users and script writers to take advantage of the power of the .NET Framework. It introduces a number of very useful new concepts that further extend the knowledge and scripts you get in the Windows Command Prompt and Windows Script Host environment. This tutorial will explain the use of Windows PowerShell scripts in WMI.
WMI consists of three basic elements:
1.Provider -- Approve access to managed objects and provide a valid WMI API
2.Classes -- Objects have WMI statements for properties and methods
3.Namespace -- logical grouping of classes
So how does PowerShell make WMI access easier? So?
First, let's take a look at the tools PowerShell provides for WMI. Overall there are five PowerShell command sets, which makes WMI easy to use. I will list them all here, but I will only focus on one of them (Get-WMIObject):
1.Get-WmiObject—— return objects based on namespaces and provided categories
2.Invoke-WmiMethod—— Call WMI program (usually used to execute static programs)
3.Register-WmiEvent—— for subscribing to WMI events
4. Remove-WmiObject -- delete an instance of an existing WMI class (to be clear, it does not actually delete the class itself, but an instance of this class in memory)
5.Set-WmiInstance -- Create Or update an instance of an existing WMI class (use it cautiously because it actually writes to the WMI library)
Now let's solve the biggest problem in WMI and figure out what it is. And what data can be provided.
You can rely on the following code to write the program:
$Root = "\\\\.\\ROOT:__namespace"
$WMIProv = New-Object System.Management .ManagementClass
($Root)
$WMIProv.GetInstances() |
Select Name (However, this is more complicated than other tasks. Fortunately, you don't have to do this often.)
Here's how you can list the classes provided by a specific namespace (the default is Root\\CIM2, It includes all Microsoft Win32 classes):
# On local machine
Get-WmiObject –Namespace Root\\SecurityCenter –List
# On Remote machine
Get-WmiObject –Namespace Root\\SecurityCenter –List
–Computer core
# To filter you can use wildcards
Get-WmiObject –Namespace Root\\SecurityCenter –List
*firewall*
# To list the classes for HyperV on remote server
Get-WmiObject –Namespace Root\\Virtualization –List< Br>
–Computer core (This is very difficult, but you can cheat through WMI browser or Microsoft's PowerShell Scriptomatic and other free tools.) Previous 12 Next page Total 2 pages
Ghost is a hard disk backup and recovery tool that everyone is familiar with. If you dont know how t
Notepad has many advantages, such as small size, small size, small memory, and of c
We often use a USB flash drive to copy or save data, but sometimes there are some p
In daily work, sometimes we need to extract all the file names in the folder and store them in anoth
Using the method to delete the blank lines in the Excel table makes the table more refreshing
How to open the VXP file of WinXP system? How to open a VCF file
A few very practical operation skills in XP
Remotely manage WindowsXP with DW NT in five steps
WinXP Task Manager is disabled by the administrator How to open?
Teach you a trick Solve the problem of the drive letter disappeared under XP system
What should I do if the WinXP computer network is unstable?
How to solve the garbled problem of Windows XP printing text fonts
What should I do if the WinXP system IE is tampered with?
The eight secret techniques let you use the computer without traces
How does WinXP turn off automatic updates? Turn off automatic update method
Win7 sounds big and small solution
Teach you how to restore the boot menu in Windows
Win7 display text garbled solution
A few simple steps let you change the name of the recycle bin at will
Win10 upgrade 9879 failed error code solving tutorial
Win7 quick location temporary folder tips
Win8 uses optimization master to crack third-party theme default limit tutorial
Tip: Turn off XP Top Ten Hazards Improve System Security (1)
One-click to start the computer application is no longer a dream