Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nutanix report errors with word or html #12

Open
aalexanian opened this issue Sep 17, 2021 · 14 comments
Open

Nutanix report errors with word or html #12

aalexanian opened this issue Sep 17, 2021 · 14 comments
Assignees
Labels
bug Something isn't working

Comments

@aalexanian
Copy link

Describe the bug
I ran the Nutanix as build report for the first time on two different clusters and got the exact error.
New-AsBuiltReport : Cannot bind argument to parameter 'Name' because it is an empty string.
At line:1 char:1

  • New-AsBuiltReport -Report Nutanix.PrismElement -Target '10.11.65.10' ...

Screenshot
Nutanix error

Desktop (please complete the following information):

  • OS: [Windows 2016]
  • Browser [e.g. chrome, safari]
  • powershell Version [5.1.14393.4583]
  • AOS 5.20.1.1 and 5.15.6
@aalexanian
Copy link
Author

To Reproduce
I'm using the following to run the script: New-AsBuiltReport -Report Nutanix.PrismElement -Target 10.11.65.10 -Credential (Get-Credential) -Format HTML,Word -OutputPath 'C:\Scripts\Asbuild-output' -TimeStamp -Verbose

Expected behavior
expect it to finish the run without errors and produce the files.

I changed the info level to the following infolevel settings and still got the exact error!
"InfoLevel": {
"comment": "0 = Disabled, 1 = Enabled / Summary, 2 = Detailed, 3 = Adv Detailed, 4 = Comprehensive",
"Cluster": 0,
"System": 2,
"Hosts": 0,
"Storage": 0,
"VM": 0,
"DataProtection": 0
},
the I changed it to
"InfoLevel": {
"comment": "0 = Disabled, 1 = Enabled / Summary, 2 = Detailed, 3 = Adv Detailed, 4 = Comprehensive",
"Cluster": 1,
"System": 0,
"Hosts": 0,
"Storage": 0,
"VM": 0,
"DataProtection": 0
},

@tpcarman
Copy link
Contributor

@aalexanian can you disable all InfoLevel sections and tell me if the report generates? This will help me diagnose where the problem might be.
Also, did you modify the default report JSON file or generate one? If you have generated one, you with need to specify the ReportConfigFilePath parameter

@aalexanian
Copy link
Author

aalexanian commented Sep 17, 2021 via email

@pettcomputers
Copy link

I'm also having this issue, but even after disabling all info levels, I still get the same error as OP. The only difference is we're using AOS. 5.15.7 LTS and not 5.15.6

@tpcarman
Copy link
Contributor

tpcarman commented Jul 7, 2022

Which hypervisor are you both running?

@pettcomputers
Copy link

Mix of ESXi and AHV (Storage only Nodes)

@tpcarman tpcarman added the bug Something isn't working label Jul 8, 2022
@tpcarman tpcarman self-assigned this Jul 8, 2022
@tpcarman
Copy link
Contributor

tpcarman commented Jul 8, 2022

Leave it with me. I'll see if I can get a lab spun up next week to do some further testing.

@pettcomputers
Copy link

Thank you

@pettcomputers
Copy link

Hi @tpcarman, just checking in to see if you'd had a chance to look at this any yet. Thanks

@tpcarman
Copy link
Contributor

@pettcomputers unfortunately I cannot get access to a mixed ESXi & AHV environment like yours, however if you're willing to try and run some code we might be able to identify the issue. Modify the first line of the code below and replace <cluster IP> with your Nutanix Prism / Cluster IP. Then, open a new PowerShell console and copy and paste each of the code snippets into the console. Once complete you should hopefully have your cluster name returned.

$ntnxpe = <cluster IP> # Replace with your Prism / Cluster IP
$credential = get-credential # When prompted, enter Prism credentials
function Get-NtnxApi {

    [CmdletBinding()]
    param (
        [Parameter(
            Mandatory = $true
        )]
        [ValidateNotNullOrEmpty()]
        [Int] $Version,

        [Parameter(
            Mandatory = $true
        )]
        [ValidateNotNullOrEmpty()]
        [String] $Uri
    )

    Begin {
    #region Workaround for SelfSigned Cert an force TLS 1.2
    if (-not ([System.Management.Automation.PSTypeName]'ServerCertificateValidationCallback').Type) {
        $certCallback = @"
        using System;
        using System.Net;
        using System.Net.Security;
        using System.Security.Cryptography.X509Certificates;
        public class ServerCertificateValidationCallback
        {
            public static void Ignore()
            {
                if(ServicePointManager.ServerCertificateValidationCallback ==null)
                {
                    ServicePointManager.ServerCertificateValidationCallback +=
                        delegate
                        (
                            Object obj,
                            X509Certificate certificate,
                            X509Chain chain,
                            SslPolicyErrors errors
                        )
                        {
                            return true;
                        };
                }
            }
        }
"@
        Add-Type $certCallback
    }
    [ServerCertificateValidationCallback]::Ignore()
    [Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"
    #endregion Workaround for SelfSigned Cert an force TLS 1.2

        $username = $Credential.UserName
        $password = $Credential.GetNetworkCredential().Password
        $auth = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($username + ":" + $password ))
        $api_v1 = "https://" + $NtnxPE + ":9440/PrismGateway/services/rest/v1"
        $api_v2 = "https://" + $NtnxPE + ":9440/PrismGateway/services/rest/v2.0"
        $headers = @{
            'Accept'        = 'application/json'
            'Authorization' = "Basic $auth"
            'Content-Type'  = 'application/json'
        }
    }

    Process {
        Try {
            Write-PScriboMessage -Message "Performing API reference call to $(($URI).TrimStart('/')) [$NtnxPE]"
            # Check PowerShell version
            if ($PSVersionTable.PSVersion.Major -eq "7") {
                Switch ($Version) {
                    '1' { Invoke-RestMethod -Method Get -Uri ($api_v1 + $uri) -Headers $headers -SkipCertificateCheck }
                    '2' { Invoke-RestMethod -Method Get -Uri ($api_v2 + $uri) -Headers $headers -SkipCertificateCheck }
                }
            } elseif ($PSVersionTable.PSVersion.Major -eq "5") {
                Switch ($Version) {
                    '1' { Invoke-RestMethod -Method Get -Uri ($api_v1 + $uri) -Headers $headers }
                    '2' { Invoke-RestMethod -Method Get -Uri ($api_v2 + $uri) -Headers $headers }
                }
            } else {
                Throw
            }
        } Catch {
            Write-Verbose -Message "Error with API reference call to $(($URI).TrimStart('/')) [$NtnxPE]"
            Write-Verbose -Message $_
        }
    }

    End {}
}
$NtnxCluster = Get-NtnxApi -Version 2 -Uri '/cluster'
$NtnxCluster | Select-Object -ExpandProperty Name

@antdolan
Copy link

antdolan commented Mar 7, 2023

I am still having this issue above. Have narrowed it down to System InfoLevel. It successfully runs with all InfoLevels set to 0. Then changing them 1 at a time & errors when system is changed from 0.
I am running a pure ESXi environment. Also ran your code test above. It does NOT return the cluster name.
I have also tried removing latest ver 1.2.1 & installing older 1.2.0.1 with same error
Have tried running on both PS 5.1 & 7.3.3

OS: Windows 10
powershell Version 5.1.19041.2673 & 7.3.3
AOS 6.5.2.5
ESXi 7u3k

@TMW999
Copy link

TMW999 commented Jun 22, 2023

Still seeing this issue. Running with multiple versions of AOS 5.4.x & 6.5.x. Pure ESXi environment.
any time would be appreciated to help solve.

@tpcarman
Copy link
Contributor

@TMW999 have you tried running the code from my comments above?

@adbdfw
Copy link

adbdfw commented Jul 25, 2023

@tpcarman I am having the same issue as @aalexanian .. I am an all Nutanix environment.. yes I have ran the above test you provided and I return no results..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants