Functions/Connect-VmSession.ps1
function Connect-VmSession { [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [ArgumentCompleter( { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters ) Get-VM "$wordToComplete*" | ForEach-Object { $_.Name } } )] [ValidateScript( { $_ -in ((Get-VM).Name) } ) ] [string] $VMName ) Get-VM $VMName vmconnect.exe $env:COMPUTERNAME $VMName } |