-
Notifications
You must be signed in to change notification settings - Fork 0
/
Pee-Object.ps1
70 lines (46 loc) · 1.38 KB
/
Pee-Object.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
function Pee-Object {
[CmdletBinding()]
param (
[Parameter(Mandatory=$true,ValueFromPipeline=$true)]
[PSObject]
$InputObject
)
begin {
}
process {
Write-Host $InputObject;
Write-Output $InputObject;
}
end {
}
<#
.SYNOPSIS
Prints command output console and also sends it down the pipeline.
.DESCRIPTION
The Pee-Object cmdlet redirects output, that is, it sends the output of a command one way and then loops back around to output it (like the letter P). It prints the output to the console and also sends it down the pipeline. It is like Tee-Object, but for Printing.
.PARAMETER InputObject
Specifies the object to be displayed and output. Enter a variable that contains the objects or type a command or expression that gets the objects. You can also pipe an object to Pee-Object.
.INPUTS
You may pipe objects to Pee-Object.
.OUTPUTS
System.Management.Automation.PSObject.
Tee-Object returns the object that it redirects.
.EXAMPLE
PS> Get-PSDrive -PSProvider FileSystem | Pee-Object | %{Get-ChildItem "$_`:`\" -Filter "*.txt" -Recurse -File -ErrorAction SilentlyContinue} | Measure-Object | select Count
C
D
E
F
G
Count
-----
24007
.LINK
https://github.com/DannyMeister/Pee-Object
.LINK
https://www.dannymeister.com/2019/03/26/pee-object.html
.LINK
Tee-Object
#>
}
Set-Alias -Name pee -Value Pee-Object;