This article introduces how to use .NET objects in PowerShell. PowerShell supports a large number of .NET objects intrinsically.
Calling static methods of the class
Enclose the class name in brackets, then enter two colons, then enter the method name, and finally the method parameters. The syntax is as follows:
[Class name]:: Method name (parameter list)
like:
Access the static properties of the class
To access static properties of .NET classes, you can use brackets to enclose the class name, enter two colons, and then enter the property name. The syntax is as follows:
[Class Name]::Attribute Name
like:
Methods to call objects
After the object variable, use point (.) as the member variable character, then add the method name and method parameters. The syntax is as follows:
$Object variable.Method (parameter list)
like:
$()
Access the properties of the object
After the object variable, use the point (.) as the member variable character, and then add the attribute name. The syntax is as follows:
$Object variable.Attribute name
like:
$
This article introduces so much about the use of .NET objects in PowerShell. I hope it will be helpful to everyone. Thank you!