Skip to content

Commit 5107aeb

Browse files
StartAutomatingStartAutomating
authored andcommitted
Updating Assert keyword (support for pipelining) (#143)
1 parent 8fa751a commit 5107aeb

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

docs/Assert.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,22 @@ Invoke-PipeScript {
5959
} -Verbose
6060
```
6161

62+
#### EXAMPLE 5
63+
```PowerShell
64+
# assert can be used with the object pipeline. $_ will be the current object.
65+
Invoke-PipeScript {
66+
1..4 | assert {$_ % 2} "$_ is not odd!"
67+
} -Debug
68+
```
69+
70+
#### EXAMPLE 6
71+
```PowerShell
72+
# You can provide a ```[ScriptBlock]``` as the second argument to see each failure
73+
Invoke-PipeScript {
74+
1..4 | assert {$_ % 2} { Write-Error "$_ is not odd!" }
75+
} -Debug
76+
```
77+
6278
---
6379
### Parameters
6480
#### **CommandAst**

0 commit comments

Comments
 (0)