Created
October 31, 2016 22:48
-
-
Save bielawb/0735aa5d184ad9044031262ef68d61d3 to your computer and use it in GitHub Desktop.
Module that uses WMF5 completion for vmconnect wrapper.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DopelnijVMke : System.Management.Automation.IArgumentCompleter { | |
[System.Collections.Generic.IEnumerable[System.Management.Automation.CompletionResult]] CompleteArgument( | |
[string]$commandName, | |
[string]$parameterName, | |
[string]$wordToComplete, | |
[System.Management.Automation.Language.CommandAst]$commandAst, | |
[System.Collections.IDictionary]$fakeBoundParameters | |
) { | |
return [System.Management.Automation.CompletionResult[]]@( | |
foreach ($vm in Get-VM -Name "$wordToComplete*") { | |
[System.Management.Automation.CompletionResult]::new( | |
$vm.Name, | |
$vm.Name, | |
[System.Management.Automation.CompletionResultType]::ParameterValue, | |
"Wirtualna maszyna $($vm.Name)" | |
) | |
} | |
) | |
} | |
} | |
function Show-VM { | |
param ( | |
[ValidateNotNullOrEmpty()] | |
[ArgumentCompleter([DopelnijVMke])] | |
[string]$VMName = 'Mgmt', | |
[ValidateNotNullOrEmpty()] | |
[string]$ComputerName = $env:COMPUTERNAME | |
) | |
vmconnect.exe $ComputerName $VMName | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment