This article describes how to use. NET objects in PowerShell, PowerShell internally supports a large number of. NET objects.
Calling a static method of a class
Enclose the class name in brackets, enter a two colon, and then enter the method name, and finally the method's arguments. The syntax is as follows:
[Class name]:: Method Name (argument list)
Such as:
Copy Code code as follows:
[System.diagnostics.process]::getprocessbyid (0)
To access the static properties of a class
To access. NET class, you can enclose the name of the class by using brackets, then enter a two colon, and then enter the property name. The syntax is as follows:
[Class name]:: Property name
Such as:
Copy Code code as follows:
Method of calling Object
After the object variable, use the dot (.) as the member variable, followed by the method name, and the method argument. The syntax is as follows:
$ object variable. Method (parameter list)
Such as:
Copy Code code as follows:
$process = get-process Notepad
$process. WaitForExit ()
Accessing the properties of an object
Use the dot (.) as the member variable after the object variable, and then add the property name. The syntax is as follows:
$ object variable. Property name
Such as:
Copy Code code as follows:
About the use of. NET objects in PowerShell, this article on the introduction of so many, I hope to help you, thank you!