WahlNetwork / vester

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

Issue #116 - Update to ensure $object.name is correct for vCenter #129

Closed jpsider closed 7 years ago

jpsider commented 7 years ago

I chose to only update this in one location in this script. It will return the correct name in the console and xml output. The other areas with $cfg.vcenter.vc do not require this change to be functional.

jpsider commented 7 years ago

Console output Before: Describing vCenter Configuration: NFC-UseSSL.Vester.ps1 Describing vCenter Configuration: SMTP-Port.Vester.ps1 [+] vCenter - SMTP Port 758ms

Console output after change: Describing vCenter Configuration: NFC-UseSSL.Vester.ps1 Describing vCenter Configuration: SMTP-Port.Vester.ps1 [+] vCenter 192.168.10.220 - SMTP Port 501ms

Same problem with the XML that is created, which I parse for XesterUI.

brianbunke commented 7 years ago

Thanks @jpsider! As we touched on in chat, I'll sit on this until we merge #115 (which is hopefully very soon now 🙂).

jpsider commented 7 years ago

I could not get this to work : 'vCenter' { @{Name = $cfg.vcenter.vc} } I tried several different ways to specify the name, but the main problem is that $cfg.vcenter.vc is not an object, it's just a string.

I was able to add 'name' to $cfg.vcenter, but that would require more changes mainly in the test files.

So I may have hit a middle ground with the following line: 'vCenter' {$global:DefaultVIServer | where-object {$_.name -like "$($cfg.vcenter.vc)"}}

It will set the object to the connected vcenter with the name from the string in the config file.

Results with : Describing vCenter Configuration: SMTP-Port.Vester.ps1 [+] vCenter 192.168.2.200 - SMTP Port 192ms Describing VM Configuration: CDDrive-Host.Vester.ps1

I committed the changes, let me know your thoughts.

brianbunke commented 7 years ago

That works for me 🙂 Pending #115.

brianbunke commented 7 years ago

:shipit: