-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRemove-MultiDirectory.ps1
More file actions
43 lines (43 loc) · 1.15 KB
/
Remove-MultiDirectory.ps1
File metadata and controls
43 lines (43 loc) · 1.15 KB
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
<#
.SYNOPSIS
Remove piped in object with a progress bar
.DESCRIPTION
Showing a progress par with the current item and path, recusively delete the piped objects.
.EXAMPLE
PS C:\> <example usage>
Explanation of what the example does
.INPUTS
Inputs (if any)
.OUTPUTS
Output (if any)
.NOTES
General notes
#>
function Remove-MultiDirectory{
[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName)]
[System.IO.DirectoryInfo[]]
[Alias('PSPath')]
$Path
)
Begin{
}
Process{
$index = 0
foreach($f in $Path){
$index += 1
$parent = split-path -Parent $f.fullname
$progress = @{
ID = 1
Activity = 'Removing items with Recursive Force'
Status = "Removing under $parent"
CurrentOperation = "Target: $($f.name)"
}
if($PSCmdlet.ShouldProcess($f.fullname, 'Remove with Recursive Force')){
Write-Progress @progress
Remove-Item $f.fullname -Recurse -Force
}
}
}
}