@@ -440,9 +440,9 @@ function Get-VNVMByVirtualPortGroup {
440440
441441function Get-VNVMEVCInfo {
442442<# . Description
443- Code to get VMs' EVC mode and that of the cluster in which the VMs reside. May 2014, Matt Boren
443+ Function to get VMs' EVC mode and that of the cluster in which the VMs reside
444444 . Example
445- Get-VNVMEVCInfo - Cluster myCluster | ?{$_.VMEVCMode -ne $_.ClusterEVCMode}
445+ Get-Cluster myCluster | Get-VNVMEVCInfo | ?{$_.VMEVCMode -ne $_.ClusterEVCMode}
446446 Name PowerState VMEVCMode ClusterEVCMode ClusterName
447447 ---- ---------- --------- -------------- -----------
448448 myvm001 poweredOff intel-nehalem myCluster0
@@ -451,20 +451,20 @@ function Get-VNVMEVCInfo {
451451 Get all VMs in given clusters where the VM's EVC mode does not match the Cluster's EVC mode
452452
453453 . Example
454- Get-VM myVM | Get-VNVMEVCInfo
455- Get the EVC info for the given VM and the cluster in which it resides
454+ Get-VM myVM0,myVM1 | Get-VNVMEVCInfo
455+ Get the EVC info for the given VMs and the cluster in which they reside
456456
457457 . Outputs
458458 System.Management.Automation.PSCustomObject
459459#>
460460 [CmdletBinding (DefaultParameterSetName = " ByCluster" )]
461461 [OutputType ([System.Management.Automation.PSCustomObject ])]
462462 param (
463- # # Cluster name pattern (regex) to use for getting the clusters whose VMs to get
464- [parameter (ParameterSetName = " ByCluster" , Position = 0 )][string ] $Cluster = " .+ " ,
463+ # # Cluster whose VMs about which to get EVC information
464+ [parameter (ValueFromPipeline = $true , ParameterSetName = " ByCluster" , Position = 0 )][VMware.VimAutomation.Types.Cluster []] $Cluster ,
465465
466- # # Id/MoRef of VM for which to get EVC info
467- [parameter (ValueFromPipelineByPropertyName = $true , ParameterSetName = " ByVMId " , Position = 0 )][Alias ( " Id " , " MoRef " )][ string [ ]]$VMId
466+ # # VM for which to get EVC info
467+ [parameter (ValueFromPipeline = $true , ParameterSetName = " ByVM " , Position = 0 )][VMware.VimAutomation.Types.VirtualMachine [ ]]$VM
468468 ) # # end param
469469
470470 begin {
@@ -489,16 +489,16 @@ function Get-VNVMEVCInfo {
489489
490490 Switch ($PSCmdlet.ParameterSetName ) {
491491 " ByCluster" {
492- Get-View - ViewType ClusterComputeResource - Property Name, Summary - Filter @ { " Name " = $Cluster } | Foreach-Object {
492+ Get-View - Property Name, Summary - Id $Cluster.Id | Foreach-Object {
493493 $viewThisCluster = $_
494494 Get-View - ViewType VirtualMachine @hshParamForGetVMView - SearchRoot $viewThisCluster.MoRef | Foreach-Object {
495495 _New- InfoObj - VMView $_ - ClusterEVCModeKey $viewThisCluster.Summary.CurrentEVCModeKey - ClusterName $viewThisCluster.Name
496496 } # # end foreach-object
497497 } # # end foreach-object
498498 break
499499 } # # end case
500- " ByVMId " {
501- Get-View @hshParamForGetVMView - Id $VMId | Foreach-Object {
500+ " ByVM " {
501+ Get-View @hshParamForGetVMView - Id $VM .Id | Foreach-Object {
502502 # # update the View data to get the cluster name and the cluster summary (which has the cluster's EVCMode)
503503 $_.UpdateViewData (" Runtime.Host.Parent.Name" )
504504 $_.Runtime.LinkedView.Host.LinkedView.Parent.UpdateViewData (" Summary" )
0 commit comments