Explain the use of Windows PowerShell scripts

  
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 it easier to access WMI?
First, let's take a look at PowerShell as Tools provided by 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 the namespace and the 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 existing WMI class Instance (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, figure out what it is and what data it can provide.
You can rely on the following code to write the program:
$Root = "\\\\.\\ROOT:__namespace"
$WMIProv = New-Object System.Management.ManagementClass
($Root)
$WMIProv.GetInstances()
Copyright © Windows knowledge All Rights Reserved