< Back
Set-PSFScriptblock
Post
NAME Set-PSFScriptblock
SYNOPSIS
Stores a scriptblock in the central scriptblock store.
SYNTAX
Set-PSFScriptblock [-Name] <String> [-Scriptblock] <ScriptBlock> [<CommonParameters>]
DESCRIPTION
Stores a scriptblock in the central scriptblock store.
This store can be accessed using Get-PSFScriptblock.
It is used to share scriptblocks outside of scope and runspace boundaries.
Scriptblocks thus registered can be accessed by C#-based services, such as the PsfValidateScript attribute.
PARAMETERS
-Name <String>
The name of the scriptblock.
Must be unique, it is recommended to prefix the module name:
<Module>.<Scriptblock>
Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Scriptblock <ScriptBlock>
The scriptcode to register
Required? true
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
NOTES
Repeatedly registering the same scriptblock (e.g. in multi-runspace scenarios) is completely safe:
- Access is threadsafe & Runspacesafe
- Overwriting the scriptblock does not affect the statistics
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Set-PSFScriptblock -Name 'MyModule.TestServer' -Scriptblock $Scriptblock
Stores the scriptblock contained in $Scriptblock under the 'MyModule.TestServer' name.
RELATED LINKS
SYNOPSIS
Stores a scriptblock in the central scriptblock store.
SYNTAX
Set-PSFScriptblock [-Name] <String> [-Scriptblock] <ScriptBlock> [<CommonParameters>]
DESCRIPTION
Stores a scriptblock in the central scriptblock store.
This store can be accessed using Get-PSFScriptblock.
It is used to share scriptblocks outside of scope and runspace boundaries.
Scriptblocks thus registered can be accessed by C#-based services, such as the PsfValidateScript attribute.
PARAMETERS
-Name <String>
The name of the scriptblock.
Must be unique, it is recommended to prefix the module name:
<Module>.<Scriptblock>
Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Scriptblock <ScriptBlock>
The scriptcode to register
Required? true
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
NOTES
Repeatedly registering the same scriptblock (e.g. in multi-runspace scenarios) is completely safe:
- Access is threadsafe & Runspacesafe
- Overwriting the scriptblock does not affect the statistics
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Set-PSFScriptblock -Name 'MyModule.TestServer' -Scriptblock $Scriptblock
Stores the scriptblock contained in $Scriptblock under the 'MyModule.TestServer' name.
RELATED LINKS