PSScriptMethod Constructor (String, ScriptBlock)


Updated: April 27, 2016

Applies To: Windows PowerShell

Initializes a new instance of the PSScriptMethod class that contains the name of the method and the script that is run when the method is called.

Namespace:   System.Management.Automation
Assembly:  System.Management.Automation (in System.Management.Automation.dll)

public PSScriptMethod(
	string name,
	ScriptBlock script


Type: System.String

The name of the method.

Type: System.Management.Automation.ScriptBlock

The script to be run when the method is called.

Exception Condition

name is null.

For more information about script methods and other method types that can be used to extend objects, see ETS Methods [ps].

Although it is possible to derive from this class, there is no established scenario for doing this and any attempt to do so may result in unexpected behavior.

Return to top

Community Additions