# PowerShellScriptResource Constructors

- Package: [CommunityToolkit.Aspire.Hosting.PowerShell](/reference/api/csharp/communitytoolkit.aspire.hosting.powershell.md)
- Type: [PowerShellScriptResource](/reference/api/csharp/communitytoolkit.aspire.hosting.powershell/powershellscriptresource.md)
- Kind: `Constructors`
- Members: `2`

Represents a PowerShell script resource.

## PowerShellScriptResource(string, ScriptBlock, PowerShellRunspacePoolResource)

- Name: `Constructor(string, ScriptBlock, PowerShellRunspacePoolResource)`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9dc6fc02412d7398c5722840513d99965a6e98f/src/CommunityToolkit.Aspire.Hosting.PowerShell/PowerShellScriptResource.cs#L36-L54)

Initializes a new instance of the [PowerShellScriptResource](/reference/api/csharp/communitytoolkit.aspire.hosting.powershell/powershellscriptresource.md) class, representing a resource for executing PowerShell scripts.

```csharp
public class PowerShellScriptResource
{
    public PowerShellScriptResource(
        string name,
        ScriptBlock script,
        PowerShellRunspacePoolResource parent)
    {
        // ...
    }
}
```

## Parameters

- `name` (`string`)
  The name of the resource. This must be a valid resource name.
- `script` (`ScriptBlock`)
  The ScriptBlock to be executed.
- `parent` ([PowerShellRunspacePoolResource](/reference/api/csharp/communitytoolkit.aspire.hosting.powershell/powershellrunspacepoolresource.md))
  The parent [PowerShellRunspacePoolResource](/reference/api/csharp/communitytoolkit.aspire.hosting.powershell/powershellrunspacepoolresource.md) that provides the runspace pool for script execution. Cannot be null.

## Remarks

This class is designed to manage the execution of PowerShell scripts within a specified runspace pool. The script execution is tied to a cancellation token, allowing the script to be stopped when requested.

## PowerShellScriptResource(string, FileInfo, PowerShellRunspacePoolResource)

- Name: `Constructor(string, FileInfo, PowerShellRunspacePoolResource)`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9dc6fc02412d7398c5722840513d99965a6e98f/src/CommunityToolkit.Aspire.Hosting.PowerShell/PowerShellScriptResource.cs#L69-L88)

Initializes a new instance of the [PowerShellScriptResource](/reference/api/csharp/communitytoolkit.aspire.hosting.powershell/powershellscriptresource.md) class, representing a resource for executing PowerShell scripts.

```csharp
public class PowerShellScriptResource
{
    public PowerShellScriptResource(
        string name,
        FileInfo scriptFile,
        PowerShellRunspacePoolResource parent)
    {
        // ...
    }
}
```

## Parameters

- `name` (`string`)
  The name of the resource. This must be a valid resource name.
- `scriptFile` (`FileInfo`)
  The file containing the PowerShell script to be executed. Must be a valid file path and not null.
- `parent` ([PowerShellRunspacePoolResource](/reference/api/csharp/communitytoolkit.aspire.hosting.powershell/powershellrunspacepoolresource.md))
  The parent [PowerShellRunspacePoolResource](/reference/api/csharp/communitytoolkit.aspire.hosting.powershell/powershellrunspacepoolresource.md) that provides the runspace pool for script execution. Cannot be null.

## Remarks

This class is designed to manage the execution of PowerShell scripts within a specified runspace pool. The script execution is tied to a cancellation token, allowing the script to be stopped when requested.
