-
Notifications
You must be signed in to change notification settings - Fork 0
/
file-Ops.ps1
81 lines (60 loc) · 1.57 KB
/
file-Ops.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
71
72
73
74
75
76
77
78
[CmdletBinding()]
param (
[Parameter(Mandatory)]
[string]
$Path,
[Parameter(Mandatory)]
[int[]]
$Nums
)
function Read-File {
[CmdletBinding()]
param (
[Parameter(Mandatory)]
[string]
$Path
)
begin {
#$filecontent = [System.IO.File]::
}
process {
if (Test-Path -Path $Path) {
$fileContent = Get-Content -Path $Path
Write-Output $fileContent
if (-Not [string]::IsNullOrEmpty(($fileContent | Select-String "provide")) ) {
Write-Output "Contains provide"
}else {
Write-Output "does not Contains provide"
}
}
}
end {
}
}
function Write-File {
[CmdletBinding()]
param (
[Parameter(Mandatory)]
[string]
$Path,
[Parameter(Mandatory,ValueFromPipeline)]
$Num
)
begin {
$fileContentOut = "**************** `n"
}
process {
Out-File -InputObject $fileContentOut -FilePath $Path -Append
for ($i = 1; $i -lt 11; $i++) {
$fileContentOut = ""+$Num+" X "+$i+" = "+ $Num * $i+" "
Out-File -InputObject $fileContentOut -FilePath $Path -Append
#$fileContentOut = ""
}
#$fileContentOut += "###########"
}
end {
"###########" | Out-File -FilePath $Path -Append
}
}
Read-File -Path $Path
$Nums | Write-File -Path $Path