vmware / powershell-module-for-vmware-cloud-foundation-power-management

PowerShell Module for VMware Cloud Foundation Power Management
https://vmware.github.io/powershell-module-for-vmware-cloud-foundation-power-management/
BSD 2-Clause "Simplified" License
10 stars 8 forks source link

$cluster.name is empty, PowerManagement-ManagementDomain.ps1 errors out #101

Closed garlicNova closed 2 months ago

garlicNova commented 5 months ago

Code of Conduct

VMware Cloud Foundation

5.1

PowerShell Version

7.4.1

PowerCLI Version

13.2

Module Version

1.4.1

PowerVCF Version

2.4.1

Guest Operating System

windows server 2019

Environment Details

No response

Description

line: 395 the line failed due to $cluster.name is not assigned anywhere. this non assignment affected every other cmdlet calls afterwards.

Error or Debug Output

[04-02-2024_14:06:39] ERROR ERROR at Script Line 395 Write-PowerManagementLogMessage: C:\Users\kteng\Documents\PowerShell\Modules\VMware.CloudFoundation.PowerManagement\1.4.1.1009\SampleScripts\PowerManagement-ManagementDomain.ps1:101 Line | 101 | Write-PowerManagementLogMessage -Type ERROR -Message " ERROR at S … | ~~~~~~~~~~~~~ | ERROR at Script Line 395 PS C:\Users\kteng\Documents\PowerShell\Modules\VMware.CloudFoundation.PowerManagement\1.4.1.1009\SampleScripts>

Expected Behavior

the cmdlet call goes through and return correct evaluation.

Actual Behavior

cmdlet error out due to unknown parameter input.

Steps to Reproduce

install modules run sample script $sddcManagerFqdn = "sfo-vcf01.sfo.rainpole.io" $sddcManagerUser = "administrator@vsphere.local" $sddcManagerPass = "VMw@re1!"

./PowerManagement-ManagementDomain.ps1 -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass -shutdown -shutdownCustomerVm

Log Fragments and Files

No response

Screenshots

No response

References

No response

burnsjared0415 commented 5 months ago
 $status = Get-TanzuEnabledClusterStatus -server $vcServer.fqdn -user $vcUser -pass $vcPass -cluster $cluster.name
            if ($status -eq $True) {
                Write-PowerManagementLogMessage -Type ERROR -Message "Currently we are not supporting VMware Tanzu enabled domains. Exiting..."
                Exit
            }

i believe this is where the error is happening, i tried to run this command outside the script and it throws errors, any changes to the Function?

sowjuec commented 5 months ago

Hi Team, I am making this small assumption or presumption, As I don't have testbed to test this, I request any one of you to please have a look at this and try to change it as i suggest and see if it works.

 $clusterid = (Get-VCFCluster | Select-Object name, id, isdefault | Where-Object { $_.id -eq $clusterid })
 $clustername = $Clusterid.name

Above is the variable $clustername, where the name is getting saved, I think we should be using $clustername instead of cluster.name .

It is only my superficial analysis, I have not dug deep. Kindly check once and let me know