-
Notifications
You must be signed in to change notification settings - Fork 33
/
Storage.ArgumentCompleters.ps1
51 lines (42 loc) · 1.44 KB
/
Storage.ArgumentCompleters.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
## Storage module Custom Completers ##
#
# .SYNOPSIS
#
# Complete the -FriendlyName argument to *-PhysicalDisk cmdlets
#
function Storage_PhysicalDiskFriendlyNameParameterCompletion
{
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
Storage\Get-PhysicalDisk -FriendlyName "$wordToComplete*" |
Sort-Object FriendlyName |
ForEach-Object {
$name = $_.FriendlyName
$tooltip = $_.Description
if (!$tooltip)
{
# Review - maybe just use Manufacter + Model?
$tooltip = $_.UniqueId
}
New-CompletionResult $name $tooltip
}
}
#
# .SYNOPSIS
#
# Complete the -ImagePath argument to Mount-DiskImage
#
function ImagePathArgumentCompletion
{
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
Get-CompletionWithExtension $lastWord ('.iso', '.vhd', 'vhdx')
}
Register-ArgumentCompleter `
-Command ('Get-PhysicalDisk', 'Reset-PhysicalDisk', 'Set-PhysicalDisk') `
-Parameter 'FriendlyName' `
-Description 'Complete physical disk friendly names.' `
-ScriptBlock $function:Storage_PhysicalDiskFriendlyNameParameterCompletion
Register-ArgumentCompleter `
-Command 'Mount-DiskImage' `
-Parameter 'ImagePath' `
-Description 'Complete vhds and isos for Add-Type -LiteralPath' `
-ScriptBlock $function:ImagePathArgumentCompletion