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
)

Parameters

name
Type: System.String

The name of the method.

script
Type: System.Management.Automation.ScriptBlock

The script to be run when the method is called.

Exception Condition
ArgumentException

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

ADD
Show: