Skip to content

Instantly share code, notes, and snippets.

@vScripter
Created March 13, 2015 13:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vScripter/f8053300b5742803158f to your computer and use it in GitHub Desktop.
Save vScripter/f8053300b5742803158f to your computer and use it in GitHub Desktop.
function Get-OrderedVM {
[cmdletbinding()]
param (
[parameter(Mandatory = $true, Position = 0)]
[alias('VM')]
[String[]]$Name
)
$finalResult = @()
foreach ($guest in $vms) {
$guestQuery = $null
$guestQuery = Get-VM -Name $guest
$guestQuery += $finalResult
} # end foreach $guest
$finalResult
} # end function Get-OrderedVM
$vms = @('vm1', 'vm3', 'vm2', 'vm4')
Get-OrderedVM -Name $vms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment