lamw / vsphere-with-tanzu-nsxt-automated-lab-deployment

vSphere with Tanzu using NSX-T Automated Lab Deployment
212 stars 79 forks source link

Get-Vsan or New-VsanDiskGroups failing with exception #28

Open DanPhonovation opened 2 years ago

DanPhonovation commented 2 years ago

I've matched all the versions as described in this document. Even PowerCLI from 12.5 to 12.0. I've tried several rounds now.

Script gets as far as "Enabling VSAN & disabling VSAN Health Check ..."

The commands thereafter fail with:

03-31-2022_07:05:21] Enabling VSAN & disabling VSAN Health Check ...
Get-VsanClusterConfiguration:
Line |
   3 |          Get-VsanClusterConfiguration -Server $vc -Cluster $NewVCVSANC …
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | 31/03/2022 19:05:21      Get-VsanClusterConfiguration            Object reference not set to an instance of an object.
[03-31-2022_07:05:23] Querying ESXi host disks to create VSAN Diskgroups ...
[03-31-2022_07:05:23] Creating VSAN DiskGroup for 10.3.172.11 ...
New-VsanDiskGroup:
Line |
  18 |              New-VsanDiskGroup -Server $vc -VMHost $vmhost -SsdCanonic …
     |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | 31/03/2022 19:05:24      New-VsanDiskGroup               Object reference not set to an instance of an object.
[03-31-2022_07:05:24] Querying ESXi host disks to create VSAN Diskgroups ...
[03-31-2022_07:05:24] Creating VSAN DiskGroup for 10.3.172.12 ...
New-VsanDiskGroup:
Line |
  18 |              New-VsanDiskGroup -Server $vc -VMHost $vmhost -SsdCanonic …
     |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | 31/03/2022 19:05:25      New-VsanDiskGroup               Object reference not set to an instance of an object.
[03-31-2022_07:05:25] Querying ESXi host disks to create VSAN Diskgroups ...
[03-31-2022_07:05:25] Creating VSAN DiskGroup for 10.3.172.13 ...
New-VsanDiskGroup:
Line |
  18 |              New-VsanDiskGroup -Server $vc -VMHost $vmhost -SsdCanonic …
     |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | 31/03/2022 19:05:27      New-VsanDiskGroup               Object reference not set to an instance of an object.

All the VMs seem deployed. I can actually login to VCSA (which clearly shows some setup problems, as expected. Script isn't done).

I manually connect to it with Connect-VIServer and issue a simple "Get-VsanClusterConfiguration" and I get the same error. Not sure how to proceed.

I sure would like a lab without building it from the ground up myself. Heh.

DanPhonovation commented 2 years ago

So I tried doing the troubleshooting step is non-Core powershell, and the result is different! I get a result from Get-VsanClusterConfiguration.

Now I'm kind of confused.

Get-VsanClusterConfiguration fails with this:

PS C:\Windows\System32> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.2.2
PSEdition                      Core
GitCommitId                    7.2.2
OS                             Microsoft Windows 10.0.19043
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

But does not with:

PS C:\Windows\system32> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.19041.1320
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.1320
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Yet you're calling for PowerShell core specifically.

DanPhonovation commented 2 years ago

I looked up your latest date (11 months ago) and matched the latest stable release at the time, and it passes the sniff test. Get-VsanClusterConfiguration works with PowerShell Core 7.0 but not 7.2. Not sure about 7.1

PS C:\Program Files\PowerShell\7> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.0.6
PSEdition                      Core
GitCommitId                    7.0.6
OS                             Microsoft Windows 10.0.19043
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

^^^^ Works

I suggest changing (until a further update by yourself) the line that says "latest version of PowerShell Core" for now.

PS C:\Program Files\PowerShell\7> Get-VsanClusterConfiguration

Cluster              VsanEnabled  IsStretchedCluster   Last HCL Updated
-------              -----------  ------------------   ----------------
Workload-Cluster     True         False                29/03/2022 16:19:00
syangsao commented 2 years ago

Just confirmed this as well. I was on PSVersion 7.2.2 (VSCode auto upgraded from my previous working version) and was hitting this error.

Reinstalled PSVersion 7.0.0 and the script works fine again.

Thanks for posting the workaround @DanPhonovation !