Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ScriptBlock Class

 

Updated: April 27, 2016

Applies To: Windows PowerShell

Represents a precompiled block of script text that can be used as a single unit.

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

System.Object
  System.Management.Automation.ScriptBlock

[SerializableAttribute]
public class ScriptBlock : ISerializable

NameDescription
System_CAPS_protmethodScriptBlock(SerializationInfo, StreamingContext)

Initializes a new instance of the ScriptBlock class that contains serialization information. Introduced in Windows PowerShell 3.0.x

NameDescription
System_CAPS_pubpropertyAst

Returns the AST corresponding to the script block. Introduced in Windows PowerShell 3.0.

System_CAPS_pubpropertyAttributes

Gets the attributes of the script block.

System_CAPS_pubpropertyDebuggerHidden

Determines if the debugger is hidden. Introduced in Windows PowerShell 4.0.

System_CAPS_pubpropertyFile

Gets the file where the script block is defined. This property is introduced in Windows PowerShell 2.0.

System_CAPS_pubpropertyId

The unique ID of this script block.

System_CAPS_pubpropertyIsConfiguration

Get/set whether this scriptblock is a Configuration. Introduced in Windows PowerShell 4.0.

System_CAPS_pubpropertyIsFilter

Gets or sets a value that indicates whether the script block is a filter.

System_CAPS_pubpropertyModule

Gets information about the module where the script block is defined. This property is introduced in Windows PowerShell 2.0.

System_CAPS_pubpropertyStartPosition

Gets the token that indicates the starting position of the script block.This property is introduced in Windows PowerShell 2.0.

NameDescription
System_CAPS_pubmethodCheckRestrictedLanguage(IEnumerable<String>, IEnumerable<String>, Boolean)

Checks whether the script block uses any language constructs that are not allowed in restricted language mode. Introduced in Windows PowerShell 3.0.

System_CAPS_pubmethodSystem_CAPS_staticCreate(String)

Initializes a new instance of the ScriptBlock class that contains the specified script. This method is introduced in Windows PowerShell 2.0.

System_CAPS_pubmethodEquals(Object)

(Inherited from Object.)

System_CAPS_protmethodFinalize()

(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

(Inherited from Object.)

System_CAPS_pubmethodGetNewClosure()

Retrieves a script block that is bound to a module. This method is introduced in Windows PowerShell 2.0.

System_CAPS_pubmethodGetObjectData(SerializationInfo, StreamingContext)

Populates an object with the data needed to serialize the ScriptBlock. Introduced in Windows PowerShell 3.0.

System_CAPS_pubmethodGetPowerShell(Boolean, Object[])

Returns PowerShell object representing the pipeline contained in this ScriptBlock, similar to the GetPowerShell() method. If the 'isTrustedInput' flag parameter is set to True, then the GetPowerShell() implementation supports extended conversion operations (such as replacing variable values with their current values) that might otherwise be unsafe if applied to untrusted input. Introduced in Windows PowerShell 3.0.

System_CAPS_pubmethodGetPowerShell(Dictionary<String, Object>, Dictionary<String, Object>, Boolean, Object[])

Returns PowerShell object representing the pipeline contained in this ScriptBlock, using variables supplied in the dictionary. Introduced in Windows PowerShell 3.0.

System_CAPS_pubmethodGetPowerShell(Dictionary<String, Object>, Dictionary<String, Object>, Object[])

Returns a PowerShell object that represents the pipeline of the script block, using variables supplied in the dictionary. Introduced in Windows PowerShell 3.0.

System_CAPS_pubmethodGetPowerShell(Dictionary<String, Object>, Object[])

Returns a PowerShell object that represents the pipeline of the script block, using variables supplied in the dictionary. Introduced in Windows PowerShell 3.0.

System_CAPS_pubmethodGetPowerShell(Object[])

Returns a PowerShell object that represents the pipeline of the script block. This method is introduced in Windows PowerShell 2.0.

System_CAPS_pubmethodGetSteppablePipeline()

Retrieves a pipeline that can be used to change how a cmdlet process its input records. This method is introduced in Windows PowerShell 2.0.

System_CAPS_pubmethodGetSteppablePipeline(CommandOrigin)

Retrieves a pipeline whose commands behave based on a specified command origin. This method is introduced in Windows PowerShell 2.0.

System_CAPS_pubmethodGetSteppablePipeline(CommandOrigin, Object[])

Get a steppable pipeline object.

This element is introduced in Windows PowerShell 5.0.

System_CAPS_pubmethodGetType()

(Inherited from Object.)

System_CAPS_pubmethodInvoke(Object[])

Invokes the script block with the specified arguments, returning the results as PSObject objects.

System_CAPS_pubmethodInvokeReturnAsIs(Object[])

Runs the script block with the specified arguments. This method returns the raw (unwrapped) result objects so that it can be more efficient.

System_CAPS_pubmethodInvokeWithContext(Dictionary<String, ScriptBlock>, List<PSVariable>, Object[])

A method that allows a scriptblock to be invoked with additional context in the form of a set of local functions and variables to be defined in the scriptblock's scope. The list of variables may include the special variables $input, $_ and $this. Introduced in Windows PowerShell 4.0.

System_CAPS_pubmethodInvokeWithContext(IDictionary, List<PSVariable>, Object[])

A method that allows a scriptblock to be invoked with additional context in the form of a set of local functions and variables to be defined in the scriptblock's scope. The list of variables may include the special variables $input, $_ and $this. This overload of the function takes a hashtable and converts it to the required dictionary which makes the API easier to use from within a PowerShell script. Introduced in Windows PowerShell 4.0.

System_CAPS_protmethodMemberwiseClone()

(Inherited from Object.)

System_CAPS_pubmethodToString()

Converts the current ScriptBlock object to a string.(Overrides Object.ToString().)

A script block is a collection of statements or expressions that can be used as a single unit. Script blocks can be used to invoke a block of code as if it was a single command, or they can be assigned to variables that can be run.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: