I’ve reported your thread so moderators know it should be moved to the correct area for ESXi.
I tried this this but couldn't make it work:
$AllDisks = get-vmhost | Get-ScsiLun | select CanonicalName | where {$_.CanonicalName -like "naa.*"}
$DataStoreDisks = Get-Datastore | select @{N='DiskName'; E={$_.ExtensionData.Info.VMFS.extent.diskname}} | where {$_.DiskName -like "naa.*"}
$NotConsumed = $AllDisks | Where-Object { $_ -notin $DataStoreDisks }
The -notin comparison operator does not work for some reason.
I found this though which looks like it might get you close to what you want:
PowerCLI Script that outputs a list of all LUN paths for all ESXi hosts · GitHub
This produces output like:
1 host(s) needs to be processed. Please wait...
Hostname Datastore CanonicalName # of Paths Path State
-------- --------- ------------- ---------- ----------
10.0.1.22 MY_LUN_NR_01 naa.1234a5678901b2000000000000000003 2 {Active, Active}
10.0.1.22 naa.1234a5678901b2000000000000000005 2 {Active, Active}
10.0.1.22 naa.1234a5678901b2000000000000000021 2 {Active, Active}
10.0.1.22 mpx.vmhba32:C0:T0:L0 1 Active
10.0.1.22 naa.1234a5678901b701000000000000010d 2 {Active, Active}
10.0.1.22 naa.1234a5678901b701000000000000010e 2 {Active, Active}
10.0.1.22 naa.1234a5678901b2010000000000000013 2 {Active, Active}
10.0.1.22 MY_LUN_NR_02 naa.1234a5678901b7000000000000000508 2 {Active, Active}
10.0.1.22 naa.1234a5678901b2010000000000000014 2 {Active, Active}
10.0.1.22 MY_LUN naa.1234a5678901b70000000000000004ac 4 {Active, Active, Active, Active}
In this example all entries without a Datastore name are "not consumed".