-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathImport-Content.ps1
More file actions
42 lines (40 loc) · 934 Bytes
/
Import-Content.ps1
File metadata and controls
42 lines (40 loc) · 934 Bytes
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
function Import-Content
{
<#
.Description
Reads the content of files using System.IO.File
.Example
Import-Content -Path $Path
.Example
Get-ChildItem -Filter *.txt | Import-Content -Raw
#>
param(
[Parameter(
Mandatory=$true,
ValueFromPipeline = $true,
Position = 0
)]
[ValidateNotNullOrEmpty()]
[string[]]
$Path,
[switch]
$Raw
)
process
{
foreach( $file in ( Resolve-Path -Path $Path ) )
{
if(Test-Path -Path $file -PathType Leaf)
{
if($Raw)
{
[System.IO.File]::ReadAllText( $file )
}
else
{
[System.IO.File]::ReadAllLines( $file )
}
}
}
}
}