Skip to content

Commit aaa6ceb

Browse files
StartAutomatingStartAutomating
authored andcommitted
Updating PipeScript.HelpOut.ps1 (#56)
1 parent a94eddf commit aaa6ceb

File tree

1 file changed

+109
-0
lines changed

1 file changed

+109
-0
lines changed

docs/ValidateScriptBlock.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
2+
ValidateScriptBlock
3+
-------------------
4+
### Synopsis
5+
Validates Script Blocks
6+
7+
---
8+
### Description
9+
10+
Validates Script Blocks for a number of common scenarios.
11+
12+
---
13+
### Examples
14+
#### EXAMPLE 1
15+
```PowerShell
16+
{
17+
param(
18+
[ValidateScriptBlock(Safe)]
19+
[ScriptBlock]
20+
$ScriptBlock
21+
)
22+
```
23+
$ScriptBlock
24+
} | .>PipeScript
25+
#### EXAMPLE 2
26+
```PowerShell
27+
{
28+
param(
29+
[ValidateScriptBlock(NoBlock,NoParameters)]
30+
[ScriptBlock]
31+
$ScriptBlock
32+
)
33+
```
34+
$ScriptBlock
35+
} | .>PipeScript
36+
#### EXAMPLE 3
37+
```PowerShell
38+
{
39+
param(
40+
[ValidateScriptBlock(OnlyParameters)]
41+
[ScriptBlock]
42+
$ScriptBlock
43+
)
44+
```
45+
$ScriptBlock
46+
} | .>PipeScript
47+
---
48+
### Parameters
49+
#### **DataLanguage**
50+
51+
If set, will validate that ScriptBlock is "safe".
52+
This will attempt to recreate the Script Block as a datalanguage block and execute it.
53+
54+
55+
56+
|Type |Requried|Postion|PipelineInput|
57+
|--------------|--------|-------|-------------|
58+
|```[Switch]```|false |named |false |
59+
---
60+
#### **ParameterOnly**
61+
62+
If set, will ensure that the [ScriptBlock] only has parameters
63+
64+
65+
66+
|Type |Requried|Postion|PipelineInput|
67+
|--------------|--------|-------|-------------|
68+
|```[Switch]```|false |named |false |
69+
---
70+
#### **NoBlock**
71+
72+
If set, will ensure that the [ScriptBlock] has no named blocks.
73+
74+
75+
76+
|Type |Requried|Postion|PipelineInput|
77+
|--------------|--------|-------|-------------|
78+
|```[Switch]```|false |named |false |
79+
---
80+
#### **NoParameter**
81+
82+
If set, will ensure that the [ScriptBlock] has no parameters.
83+
84+
85+
86+
|Type |Requried|Postion|PipelineInput|
87+
|--------------|--------|-------|-------------|
88+
|```[Switch]```|false |named |false |
89+
---
90+
#### **VariableAST**
91+
92+
A VariableExpression. If provided, the Validation attributes will apply to this variable.
93+
94+
95+
96+
|Type |Requried|Postion|PipelineInput |
97+
|-----------------------------|--------|-------|--------------|
98+
|```[VariableExpressionAst]```|true |named |true (ByValue)|
99+
---
100+
### Syntax
101+
```PowerShell
102+
ValidateScriptBlock [-DataLanguage] [-ParameterOnly] [-NoBlock] [-NoParameter] [<CommonParameters>]
103+
```
104+
```PowerShell
105+
ValidateScriptBlock [-DataLanguage] [-ParameterOnly] [-NoBlock] [-NoParameter] -VariableAST <VariableExpressionAst> [<CommonParameters>]
106+
```
107+
---
108+
109+

0 commit comments

Comments
 (0)