WahlNetwork / vester

Easily validate and remediate your vSphere configuration
https://wahlnetwork.com
Apache License 2.0
146 stars 45 forks source link

Get-Cluster throws errors while running New-VesterConfig #177

Closed krobe closed 7 years ago

krobe commented 7 years ago

Current Behavior

Get-Cluster : 9/13/2017 6:10:46 PM      Get-Cluster             VMHost parameter: Could not find any of the objects specified by name.
At C:\Program Files\WindowsPowerShell\Modules\vester\1.2.0\Public\New-VesterConfig.ps1:153 char:33
+ ...   $Cluster    = $Datacenter | Get-Cluster -Name $config.scope.cluster
+                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (VMware.VimAutom...VMHost[] VMHost:RuntimePropertyInfo) [Get-Cluster], ObnRecordProcessingFailedException
    + FullyQualifiedErrorId : Core_ObnSelector_SetNewParameterValue_ObjectNotFoundCritical,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetCluster

It appears that in my environment at least piping an array of DataCenter objects to Get-Cluster does not work. Get-Cluster assumes the objects in the pipeline apply to the VMHost parameter.

Possible Solution

Changing

$Cluster = $Datacenter | Get-Cluster -Name $config.scope.cluster

to explicitly specify that the object in the pipeline is a location like:

$Cluster = $Datacenter | Foreach-Object {Get-Cluster -Name $config.scope.cluster -Location $_}

seems to work.

Steps to Reproduce (for bugs)

Simplest way I can replicate it does not involve Vester, just run Get-Datacenter | Get-Cluster against a vCenter server with multiple DataCenters.

Your Environment

midacts commented 7 years ago

Do you have a datacenter specified?

I Corinthians 15:1-4

On Fri, Sep 15, 2017 at 1:46 PM, krobe notifications@github.com wrote:

Current Behavior

Get-Cluster : 9/13/2017 6:10:46 PM Get-Cluster VMHost parameter: Could not find any of the objects specified by name. At C:\Program Files\WindowsPowerShell\Modules\vester\1.2.0\Public\New-VesterConfig.ps1:153 char:33

  • ... $Cluster = $Datacenter | Get-Cluster -Name $config.scope.cluster
  • 
    + CategoryInfo          : ObjectNotFound: (VMware.VimAutom...VMHost[] VMHost:RuntimePropertyInfo) [Get-Cluster], ObnRecordProcessingFailedException
    + FullyQualifiedErrorId : Core_ObnSelector_SetNewParameterValue_ObjectNotFoundCritical,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetCluster

It appears that in my environment at least piping an array of DataCenter objects to Get-Cluster does not work. Get-Cluster assumes the objects in the pipeline apply to the VMHost parameter. Possible Solution

Changing

$Cluster = $Datacenter | Get-Cluster -Name $config.scope.cluster

to explicitly specify that the object in the pipeline is a location like:

$Cluster = $Datacenter | Foreach-Object {Get-Cluster -Name $config.scope.cluster -Location $_}

seems to work. Steps to Reproduce (for bugs)

Simplest way I can replicate it does not involve Vester, just run Get-Datacenter | Get-Cluster against a vCenter server with multiple DataCenters. Your Environment

  • Vester module version used: 1.2.0
  • PowerCLI version: 6.5.2.6268016
  • Pester version: 4.0.7
  • Operating System: Windows 7 SP1
  • PowerShell version: 5.1.14409.1012

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/WahlNetwork/Vester/issues/177, or mute the thread https://github.com/notifications/unsubscribe-auth/ADxtkArG6_SEA6SjA8C6JOkmtHZ2KA8Xks5sirfYgaJpZM4PZTKI .

brianbunke commented 7 years ago

Welcome, @krobe!

We discovered this is a PowerCLI bug in #167. (Like you said, Get-Datacenter | Get-Cluster is an easy reproduce when datacenters > 1.) Expect it to be fixed in the next release, after 6.5.2.

I believe (hope?) it's an easy fix, and it's currently up for grabs if anyone's interested in contributing it back to the module.

krobe commented 7 years ago

I have submitted PR #180 for review.

brianbunke commented 7 years ago

Resolved in #180 🎉