-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTest-MultiPath.ps1
More file actions
66 lines (61 loc) · 1.96 KB
/
Test-MultiPath.ps1
File metadata and controls
66 lines (61 loc) · 1.96 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<#
.SYNOPSIS
Test a given path if it is accessible
.DESCRIPTION
This cmdlet returns an object that contains the path that was tested to easily find failing paths.
.EXAMPLE
.EXAMPLE
New-ComputerList u04 (2..10) -unc | %{ $_.path + 'printerConfig' } | Test-MultiPath
Test Path
---- ----
True \\u04PC02\c$\printerConfig
True \\u04PC03\c$\printerConfig
True \\u04PC04\c$\printerConfig
True \\u04PC05\c$\printerConfig
True \\u04PC06\c$\printerConfig
True \\u04PC07\c$\printerConfig
True \\u04PC08\c$\printerConfig
True \\u04PC09\c$\printerConfig
True \\u04PC10\c$\printerConfig
.EXAMPLE
New-ComputerList u04 (2..4) -unc | Copy-MultiItem '\\u04pc01\c$\printerConfig' -passthru | Test-Multipath
Test Path
---- ----
True \\u04PC02\c$\printerConfig
True \\u04PC03\c$\printerConfig
True \\u04PC04\c$\printerConfig
.EXAMPLE
Copy-MultiItem '\\u04pc01\c$\LOCAL.PRT' (New-ComputerList -Room u04 -computer (2..10) -unc).path -passThru | Test-Multipath
Test Path
---- ----
True \\u04PC02\c$\LOCAL.PRT
True \\u04PC03\c$\LOCAL.PRT
True \\u04PC04\c$\LOCAL.PRT
...
.OUTPUTS
Object containing the test result and the path tested.
#>
function Test-MultiPath {
[CmdletBinding(PositionalBinding=$false,
ConfirmImpact='Medium')]
[OutputType([PSCustomObject])]
Param (
# Specifies a path to be tested. Wildcard characters are permitted. If the path includes spaces, enclose it in quotation marks.
[Parameter(Mandatory=$true,
Position=0,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true)]
[ValidateNotNull()]
[ValidateNotNullOrEmpty()]
[string[]]
$Path
)
Process {
$path | foreach {
New-Object -TypeName PSCustomObject -property @{
Test = Test-path $PSItem
Path = $PSItem
}
}
}
}