-
-
Save vexx32/a55d5f778cd4e115ed18d0e0a0958efd to your computer and use it in GitHub Desktop.
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
[CmdletBinding()] | |
param( | |
[Parameter(Mandatory, HelpMessage="Enter one or more VM names separated by commas. Value should not be null or empty")] | |
[ArgumentCompleter( | |
{ | |
param($Command, $Parameter, $WordToComplete, $CommandAst, $FakeBoundParams) | |
if ($WordToComplete) { | |
@((Get-VM).Name) -match "^$WordToComplete" | |
} | |
else { | |
(Get-VM).Name | |
} | |
} | |
)] | |
[ValidateScript( | |
{ | |
foreach ($Name in $_) { | |
if (-not (Get-VM $Name -ErrorAction SilentlyContinue)) { | |
throw "Please enter a valid VM Name." | |
} | |
} | |
} | |
)] | |
[String[]] | |
$servername | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment