<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comments on: LUN report &#8211; datastore, RDM and node visibility	</title>
	<atom:link href="https://www.lucd.info/2010/04/09/lun-report-datastores-rdms-and-node-visibility/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.lucd.info/2010/04/09/lun-report-datastores-rdms-and-node-visibility/</link>
	<description>My PowerShell ramblings</description>
	<lastBuildDate>Sat, 13 May 2023 13:26:59 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.9</generator>
<atom:link rel="hub" href="https://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="https://pubsubhubbub.superfeedr.com"/><atom:link rel="hub" href="https://websubhub.com/hub"/>	<item>
		<title>
		By: George		</title>
		<link>https://www.lucd.info/2010/04/09/lun-report-datastores-rdms-and-node-visibility/#comment-21998</link>

		<dc:creator><![CDATA[George]]></dc:creator>
		<pubDate>Sat, 13 May 2023 13:26:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.lucd.info/?p=2080#comment-21998</guid>

					<description><![CDATA[I like the script and I want to use it but is not working because hosts name contains dots.

Our hosts are named with dot inside, basically IP of the host is also set as name, and script failes for this reason.

I tried to change the script but I can&#039;t make it run, maybe you can give a hint.

I tried like this:

param($clusName,$csvName=(&quot;C:\Temp\&quot; + $clusName + &quot;-LUN.csv&quot;))
$rndNum = Get-Random -Maximum 99999
$LunInfoDef = @&quot;
public string ClusterName;
public string CanonicalName;
public string UsedBy;
public string SizeMB;
&quot;@
$LunInfoDef = &quot;public struct LunInfo&quot; + $rndNum + &quot;{`n&quot; + $LunInfoDef
$esxServers = Get-Cluster $clusName &#124; Get-VMHost &#124; Sort-Object -Property Name
$esxServers &#124; %{
#$LunInfoDef += (&quot;`n`tpublic string &quot; + ($_.Name.Split(&quot;.&quot;)[0]) + &quot;;&quot;)
#$LunInfoDef += (&quot;`n`tpublic string &quot; + ($_.Name) + &quot;;&quot;)
#$LunInfoDef += (&quot;`n`tpublic string &quot; + [Regex]::Escape(($_.Name)) + &quot;;&quot;)
#$LunInfoDef += (&quot;`n`tpublic string &quot; + &quot;&quot;&quot;($_.Name)) + &quot;&quot;;&quot;)
$LunInfoDef += (&quot;`n`tpublic string &quot; + &quot;`&quot;&quot; + ($_) + &quot;`&quot;;&quot;)
}
$LunInfoDef += &quot;`n}&quot;
Add-Type -Language CsharpVersion3 -TypeDefinition $LunInfoDef
#Add-Type -Language Csharp -TypeDefinition $LunInfoDef
$scsiTab = @{}
$esxServers &#124; %{
$esxImpl = $_
# Get SCSI LUNs
$esxImpl &#124; Get-ScsiLun &#124; where {$_.LunType -eq &quot;Disk&quot;} &#124; %{
#$key = $esxImpl.Name.Split(&quot;.&quot;)[0] + &quot;-&quot; + $_.CanonicalName.Split(&quot;.&quot;)[1]
$key = $esxImpl.Name + &quot;-&quot; + $_.CanonicalName.Split(&quot;.&quot;)[1]
if(!$scsiTab.ContainsKey($key)){
$scsiTab[$key] = $_.CanonicalName,&quot;&quot;,$_.CapacityMB
}
}
# Get the VMFS datastores
$esxImpl &#124; Get-Datastore &#124; where {$_.Type -eq &quot;VMFS&quot;} &#124; Get-View &#124; %{
$dsName = $_.Name
$_.Info.Vmfs.Extent &#124; %{
#$key = $esxImpl.Name.Split(&quot;.&quot;)[0] + &quot;-&quot; + $_.DiskName.Split(&quot;.&quot;)[1]
$key = $esxImpl.Name + &quot;-&quot; + $_.DiskName.Split(&quot;.&quot;)[1]
$scsiTab[$key] = $scsiTab[$key][0], $dsName, $scsiTab[$key][2]
}
}
}


but I get this errors:
PS C:\temp\vmware&#062; .\Cluster-LUN-list.ps1 mhq
Add-Type : c:\Users\M-2329\AppData\Local\Temp\sbuzupwl.0.cs(6) : Invalid token &#039;&quot;10.1.217.10&quot;&#039; in class, struct, or interface member declaration
c:\Users\M-2329\AppData\Local\Temp\sbuzupwl.0.cs(5) : public string SizeMB;
c:\Users\M-2329\AppData\Local\Temp\sbuzupwl.0.cs(6) : &#062;&#062;&#062;       public string &quot;10.1.217.10&quot;;
c:\Users\M-2329\AppData\Local\Temp\sbuzupwl.0.cs(7) :   public string &quot;10.1.217.20&quot;;
At C:\temp\vmware\Cluster-LUN-list.ps1:19 char:1
+ Add-Type -Language CsharpVersion3 -TypeDefinition $LunInfoDef
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (Microsoft.Power...peCompilerError:AddTypeCompilerError) [Add-Type], Exception
    + FullyQualifiedErrorId : SOURCE_CODE_ERROR,Microsoft.PowerShell.Commands.AddTypeCommand

Add-Type : c:\Users\M-2329\AppData\Local\Temp\sbuzupwl.0.cs(7) : Invalid token &#039;&quot;10.1.217.20&quot;&#039; in class, struct, or interface member declaration
c:\Users\M-2329\AppData\Local\Temp\sbuzupwl.0.cs(6) :   public string &quot;10.1.217.10&quot;;
c:\Users\M-2329\AppData\Local\Temp\sbuzupwl.0.cs(7) : &#062;&#062;&#062;       public string &quot;10.1.217.20&quot;;
c:\Users\M-2329\AppData\Local\Temp\sbuzupwl.0.cs(8) :   public string &quot;10.1.217.30&quot;;
At C:\temp\vmware\Cluster-LUN-list.ps1:19 char:1
+ Add-Type -Language CsharpVersion3 -TypeDefinition $LunInfoDef
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (Microsoft.Power...peCompilerError:AddTypeCompilerError) [Add-Type], Exception
    + FullyQualifiedErrorId : SOURCE_CODE_ERROR,Microsoft.PowerShell.Commands.AddTypeCommand

Add-Type : c:\Users\M-2329\AppData\Local\Temp\sbuzupwl.0.cs(8) : Invalid token &#039;&quot;10.1.217.30&quot;&#039; in class, struct, or interface member declaration
c:\Users\M-2329\AppData\Local\Temp\sbuzupwl.0.cs(7) :   public string &quot;10.1.217.20&quot;;
c:\Users\M-2329\AppData\Local\Temp\sbuzupwl.0.cs(8) : &#062;&#062;&#062;       public string &quot;10.1.217.30&quot;;
c:\Users\M-2329\AppData\Local\Temp\sbuzupwl.0.cs(9) :   public string &quot;10.1.217.40&quot;;
At C:\temp\vmware\Cluster-LUN-list.ps1:19 char:1
+ Add-Type -Language CsharpVersion3 -TypeDefinition $LunInfoDef
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (Microsoft.Power...peCompilerError:AddTypeCompilerError) [Add-Type], Exception
    + FullyQualifiedErrorId : SOURCE_CODE_ERROR,Microsoft.PowerShell.Commands.AddTypeCommand

Add-Type : c:\Users\M-2329\AppData\Local\Temp\sbuzupwl.0.cs(9) : Invalid token &#039;&quot;10.1.217.40&quot;&#039; in class, struct, or interface member declaration
c:\Users\M-2329\AppData\Local\Temp\sbuzupwl.0.cs(8) :   public string &quot;10.1.217.30&quot;;
c:\Users\M-2329\AppData\Local\Temp\sbuzupwl.0.cs(9) : &#062;&#062;&#062;       public string &quot;10.1.217.40&quot;;
c:\Users\M-2329\AppData\Local\Temp\sbuzupwl.0.cs(10) : }
At C:\temp\vmware\Cluster-LUN-list.ps1:19 char:1
+ Add-Type -Language CsharpVersion3 -TypeDefinition $LunInfoDef
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (Microsoft.Power...peCompilerError:AddTypeCompilerError) [Add-Type], Exception
    + FullyQualifiedErrorId : SOURCE_CODE_ERROR,Microsoft.PowerShell.Commands.AddTypeCommand

Add-Type : Cannot add type. Compilation errors occurred.
At C:\temp\vmware\Cluster-LUN-list.ps1:19 char:1
+ Add-Type -Language CsharpVersion3 -TypeDefinition $LunInfoDef
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Add-Type], InvalidOperationException
    + FullyQualifiedErrorId : COMPILER_ERRORS,Microsoft.PowerShell.Commands.AddTypeCommand]]></description>
			<content:encoded><![CDATA[<p>I like the script and I want to use it but is not working because hosts name contains dots.</p>
<p>Our hosts are named with dot inside, basically IP of the host is also set as name, and script failes for this reason.</p>
<p>I tried to change the script but I can&#8217;t make it run, maybe you can give a hint.</p>
<p>I tried like this:</p>
<p>param($clusName,$csvName=(&#8220;C:\Temp\&#8221; + $clusName + &#8220;-LUN.csv&#8221;))<br />
$rndNum = Get-Random -Maximum 99999<br />
$LunInfoDef = @&#8221;<br />
public string ClusterName;<br />
public string CanonicalName;<br />
public string UsedBy;<br />
public string SizeMB;<br />
&#8220;@<br />
$LunInfoDef = &#8220;public struct LunInfo&#8221; + $rndNum + &#8220;{<code>n" + $LunInfoDef<br />
$esxServers = Get-Cluster $clusName | Get-VMHost | Sort-Object -Property Name<br />
$esxServers | %{<br />
#$LunInfoDef += ("</code>n<code>tpublic string " + ($_.Name.Split(".")[0]) + ";")<br />
#$LunInfoDef += ("</code>n<code>tpublic string " + ($_.Name) + ";")<br />
#$LunInfoDef += ("</code>n<code>tpublic string " + [Regex]::Escape(($_.Name)) + ";")<br />
#$LunInfoDef += ("</code>n<code>tpublic string " + """($_.Name)) + "";")<br />
$LunInfoDef += ("</code>n<code>tpublic string " + "</code>&#8220;&#8221; + ($_) + &#8220;<code>";")<br />
}<br />
$LunInfoDef += "</code>n}&#8221;<br />
Add-Type -Language CsharpVersion3 -TypeDefinition $LunInfoDef<br />
#Add-Type -Language Csharp -TypeDefinition $LunInfoDef<br />
$scsiTab = @{}<br />
$esxServers | %{<br />
$esxImpl = $_<br />
# Get SCSI LUNs<br />
$esxImpl | Get-ScsiLun | where {$_.LunType -eq &#8220;Disk&#8221;} | %{<br />
#$key = $esxImpl.Name.Split(&#8220;.&#8221;)[0] + &#8220;-&#8221; + $_.CanonicalName.Split(&#8220;.&#8221;)[1]<br />
$key = $esxImpl.Name + &#8220;-&#8221; + $_.CanonicalName.Split(&#8220;.&#8221;)[1]<br />
if(!$scsiTab.ContainsKey($key)){<br />
$scsiTab[$key] = $_.CanonicalName,&#8221;&#8221;,$_.CapacityMB<br />
}<br />
}<br />
# Get the VMFS datastores<br />
$esxImpl | Get-Datastore | where {$_.Type -eq &#8220;VMFS&#8221;} | Get-View | %{<br />
$dsName = $_.Name<br />
$_.Info.Vmfs.Extent | %{<br />
#$key = $esxImpl.Name.Split(&#8220;.&#8221;)[0] + &#8220;-&#8221; + $_.DiskName.Split(&#8220;.&#8221;)[1]<br />
$key = $esxImpl.Name + &#8220;-&#8221; + $_.DiskName.Split(&#8220;.&#8221;)[1]<br />
$scsiTab[$key] = $scsiTab[$key][0], $dsName, $scsiTab[$key][2]<br />
}<br />
}<br />
}</p>
<p>but I get this errors:<br />
PS C:\temp\vmware&gt; .\Cluster-LUN-list.ps1 mhq<br />
Add-Type : c:\Users\M-2329\AppData\Local\Temp\sbuzupwl.0.cs(6) : Invalid token &#8216;&#8221;10.1.217.10&#8243;&#8216; in class, struct, or interface member declaration<br />
c:\Users\M-2329\AppData\Local\Temp\sbuzupwl.0.cs(5) : public string SizeMB;<br />
c:\Users\M-2329\AppData\Local\Temp\sbuzupwl.0.cs(6) : &gt;&gt;&gt;       public string &#8220;10.1.217.10&#8221;;<br />
c:\Users\M-2329\AppData\Local\Temp\sbuzupwl.0.cs(7) :   public string &#8220;10.1.217.20&#8221;;<br />
At C:\temp\vmware\Cluster-LUN-list.ps1:19 char:1<br />
+ Add-Type -Language CsharpVersion3 -TypeDefinition $LunInfoDef<br />
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
    + CategoryInfo          : InvalidData: (Microsoft.Power&#8230;peCompilerError:AddTypeCompilerError) [Add-Type], Exception<br />
    + FullyQualifiedErrorId : SOURCE_CODE_ERROR,Microsoft.PowerShell.Commands.AddTypeCommand</p>
<p>Add-Type : c:\Users\M-2329\AppData\Local\Temp\sbuzupwl.0.cs(7) : Invalid token &#8216;&#8221;10.1.217.20&#8243;&#8216; in class, struct, or interface member declaration<br />
c:\Users\M-2329\AppData\Local\Temp\sbuzupwl.0.cs(6) :   public string &#8220;10.1.217.10&#8221;;<br />
c:\Users\M-2329\AppData\Local\Temp\sbuzupwl.0.cs(7) : &gt;&gt;&gt;       public string &#8220;10.1.217.20&#8221;;<br />
c:\Users\M-2329\AppData\Local\Temp\sbuzupwl.0.cs(8) :   public string &#8220;10.1.217.30&#8221;;<br />
At C:\temp\vmware\Cluster-LUN-list.ps1:19 char:1<br />
+ Add-Type -Language CsharpVersion3 -TypeDefinition $LunInfoDef<br />
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
    + CategoryInfo          : InvalidData: (Microsoft.Power&#8230;peCompilerError:AddTypeCompilerError) [Add-Type], Exception<br />
    + FullyQualifiedErrorId : SOURCE_CODE_ERROR,Microsoft.PowerShell.Commands.AddTypeCommand</p>
<p>Add-Type : c:\Users\M-2329\AppData\Local\Temp\sbuzupwl.0.cs(8) : Invalid token &#8216;&#8221;10.1.217.30&#8243;&#8216; in class, struct, or interface member declaration<br />
c:\Users\M-2329\AppData\Local\Temp\sbuzupwl.0.cs(7) :   public string &#8220;10.1.217.20&#8221;;<br />
c:\Users\M-2329\AppData\Local\Temp\sbuzupwl.0.cs(8) : &gt;&gt;&gt;       public string &#8220;10.1.217.30&#8221;;<br />
c:\Users\M-2329\AppData\Local\Temp\sbuzupwl.0.cs(9) :   public string &#8220;10.1.217.40&#8221;;<br />
At C:\temp\vmware\Cluster-LUN-list.ps1:19 char:1<br />
+ Add-Type -Language CsharpVersion3 -TypeDefinition $LunInfoDef<br />
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
    + CategoryInfo          : InvalidData: (Microsoft.Power&#8230;peCompilerError:AddTypeCompilerError) [Add-Type], Exception<br />
    + FullyQualifiedErrorId : SOURCE_CODE_ERROR,Microsoft.PowerShell.Commands.AddTypeCommand</p>
<p>Add-Type : c:\Users\M-2329\AppData\Local\Temp\sbuzupwl.0.cs(9) : Invalid token &#8216;&#8221;10.1.217.40&#8243;&#8216; in class, struct, or interface member declaration<br />
c:\Users\M-2329\AppData\Local\Temp\sbuzupwl.0.cs(8) :   public string &#8220;10.1.217.30&#8221;;<br />
c:\Users\M-2329\AppData\Local\Temp\sbuzupwl.0.cs(9) : &gt;&gt;&gt;       public string &#8220;10.1.217.40&#8221;;<br />
c:\Users\M-2329\AppData\Local\Temp\sbuzupwl.0.cs(10) : }<br />
At C:\temp\vmware\Cluster-LUN-list.ps1:19 char:1<br />
+ Add-Type -Language CsharpVersion3 -TypeDefinition $LunInfoDef<br />
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
    + CategoryInfo          : InvalidData: (Microsoft.Power&#8230;peCompilerError:AddTypeCompilerError) [Add-Type], Exception<br />
    + FullyQualifiedErrorId : SOURCE_CODE_ERROR,Microsoft.PowerShell.Commands.AddTypeCommand</p>
<p>Add-Type : Cannot add type. Compilation errors occurred.<br />
At C:\temp\vmware\Cluster-LUN-list.ps1:19 char:1<br />
+ Add-Type -Language CsharpVersion3 -TypeDefinition $LunInfoDef<br />
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
    + CategoryInfo          : InvalidData: (:) [Add-Type], InvalidOperationException<br />
    + FullyQualifiedErrorId : COMPILER_ERRORS,Microsoft.PowerShell.Commands.AddTypeCommand</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: LucD		</title>
		<link>https://www.lucd.info/2010/04/09/lun-report-datastores-rdms-and-node-visibility/#comment-21966</link>

		<dc:creator><![CDATA[LucD]]></dc:creator>
		<pubDate>Thu, 11 May 2023 13:56:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.lucd.info/?p=2080#comment-21966</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.lucd.info/2010/04/09/lun-report-datastores-rdms-and-node-visibility/#comment-21965&quot;&gt;Gabriel&lt;/a&gt;.

Try replacing
&lt;code&gt;
Add-Type -Language &lt;strong&gt;CsharpVersion3&lt;/strong&gt; -TypeDefinition $LunInfoDef
&lt;/code&gt;
with
&lt;code&gt;
Add-Type -Language &lt;strong&gt;Csharp&lt;/strong&gt; -TypeDefinition $LunInfoDef
&lt;/code&gt;]]></description>
			<content:encoded><![CDATA[<p>Try replacing<br />
<code><br />
Add-Type -Language <strong>CsharpVersion3</strong> -TypeDefinition $LunInfoDef<br />
</code><br />
with<br />
<code><br />
Add-Type -Language <strong>Csharp</strong> -TypeDefinition $LunInfoDef<br />
</code></p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Gabriel		</title>
		<link>https://www.lucd.info/2010/04/09/lun-report-datastores-rdms-and-node-visibility/#comment-21965</link>

		<dc:creator><![CDATA[Gabriel]]></dc:creator>
		<pubDate>Thu, 11 May 2023 13:45:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.lucd.info/?p=2080#comment-21965</guid>

					<description><![CDATA[Hello Lucd!

I tested the script in the powershell version, and it worked:

NameValue
---- -----
PSVersion 5.1.14409.1027
PSEdition Desktop

but in versions other than 5.1 and variations or version 7 of powershell, I can&#039;t generate the information.

NameValue
---- -----
PSVersion 7.3.3
PSEdition Core
GitCommitId 7.3.3
OS Microsoft Windows 10.0.19044

Some of the errors I get:

Line &#124;
   15 &#124; Add-Type -Language CsharpVersion3 -TypeDefinition $LunInfoDef
      &#124; ~~~~~~~~~~~~~~
      &#124; Cannot bind parameter &#039;Language&#039;. Cannot convert value &quot;CsharpVersion3&quot; to type &quot;Microsoft.PowerShell.Commands.Language&quot;. Error: &quot;Unable to match the identifier name CsharpVersion3
      &#124; to a valid enumerator name. Specify one of the following enumerator names and try again: CSharp&quot;
InvalidOperation: C:\Users\vmware\VMware_CLI\Cluster-LUN-list.ps1:31:1
Line &#124;
   31 &#124; $scsiTab[$key] = $scsiTab[$key][0], $dsName, $scsiTab[$key][2]
      &#124; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~
      &#124; Cannot index into a null array.
InvalidOperation: C:\Users\vmware\VMware_CLI\Cluster-LUN-list.ps1:31:1
Line &#124;
   31 &#124; $scsiTab[$key] = $scsiTab[$key][0], $dsName, $scsiTab[$key][2]

My question is this: Are there requirements to use your script? I installed framework 3.5 and still, I can&#039;t successfully run your script in the mentioned versions of powershell.

Thank you Lucd!]]></description>
			<content:encoded><![CDATA[<p>Hello Lucd!</p>
<p>I tested the script in the powershell version, and it worked:</p>
<p>NameValue<br />
&#8212;- &#8212;&#8211;<br />
PSVersion 5.1.14409.1027<br />
PSEdition Desktop</p>
<p>but in versions other than 5.1 and variations or version 7 of powershell, I can&#8217;t generate the information.</p>
<p>NameValue<br />
&#8212;- &#8212;&#8211;<br />
PSVersion 7.3.3<br />
PSEdition Core<br />
GitCommitId 7.3.3<br />
OS Microsoft Windows 10.0.19044</p>
<p>Some of the errors I get:</p>
<p>Line |<br />
   15 | Add-Type -Language CsharpVersion3 -TypeDefinition $LunInfoDef<br />
      | ~~~~~~~~~~~~~~<br />
      | Cannot bind parameter &#8216;Language&#8217;. Cannot convert value &#8220;CsharpVersion3&#8221; to type &#8220;Microsoft.PowerShell.Commands.Language&#8221;. Error: &#8220;Unable to match the identifier name CsharpVersion3<br />
      | to a valid enumerator name. Specify one of the following enumerator names and try again: CSharp&#8221;<br />
InvalidOperation: C:\Users\vmware\VMware_CLI\Cluster-LUN-list.ps1:31:1<br />
Line |<br />
   31 | $scsiTab[$key] = $scsiTab[$key][0], $dsName, $scsiTab[$key][2]<br />
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~<br />
      | Cannot index into a null array.<br />
InvalidOperation: C:\Users\vmware\VMware_CLI\Cluster-LUN-list.ps1:31:1<br />
Line |<br />
   31 | $scsiTab[$key] = $scsiTab[$key][0], $dsName, $scsiTab[$key][2]</p>
<p>My question is this: Are there requirements to use your script? I installed framework 3.5 and still, I can&#8217;t successfully run your script in the mentioned versions of powershell.</p>
<p>Thank you Lucd!</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: LucD		</title>
		<link>https://www.lucd.info/2010/04/09/lun-report-datastores-rdms-and-node-visibility/#comment-10565</link>

		<dc:creator><![CDATA[LucD]]></dc:creator>
		<pubDate>Fri, 19 Nov 2021 15:10:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.lucd.info/?p=2080#comment-10565</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.lucd.info/2010/04/09/lun-report-datastores-rdms-and-node-visibility/#comment-9931&quot;&gt;avesh sampara&lt;/a&gt;.

You remove the Export-Csv and Invoke-Item in the script.

Then create a foreach loop, and in there call the updated script for each cluster.
&lt;code&gt;
Get-Cluster &#124;
Foreach-Object -Process {
  .\Cluster-LUN-list-updated.ps1 $_.Name 
} &#124;
Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture
&lt;/code&gt;]]></description>
			<content:encoded><![CDATA[<p>You remove the Export-Csv and Invoke-Item in the script.</p>
<p>Then create a foreach loop, and in there call the updated script for each cluster.<br />
<code><br />
Get-Cluster |<br />
Foreach-Object -Process {<br />
  .\Cluster-LUN-list-updated.ps1 $_.Name<br />
} |<br />
Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture<br />
</code></p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: avesh sampara		</title>
		<link>https://www.lucd.info/2010/04/09/lun-report-datastores-rdms-and-node-visibility/#comment-9931</link>

		<dc:creator><![CDATA[avesh sampara]]></dc:creator>
		<pubDate>Sun, 07 Nov 2021 17:46:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.lucd.info/?p=2080#comment-9931</guid>

					<description><![CDATA[Hi LucD,

How to fetch the details for all the clusters  in a vcenter into one file.

Thanks,
Avesh]]></description>
			<content:encoded><![CDATA[<p>Hi LucD,</p>
<p>How to fetch the details for all the clusters  in a vcenter into one file.</p>
<p>Thanks,<br />
Avesh</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: LucD		</title>
		<link>https://www.lucd.info/2010/04/09/lun-report-datastores-rdms-and-node-visibility/#comment-4762</link>

		<dc:creator><![CDATA[LucD]]></dc:creator>
		<pubDate>Sat, 21 Dec 2019 06:01:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.lucd.info/?p=2080#comment-4762</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.lucd.info/2010/04/09/lun-report-datastores-rdms-and-node-visibility/#comment-4761&quot;&gt;David&lt;/a&gt;.

Hi David,
You can try the version below.
Instead of &#039;OK&#039; it shows the LUNid in each ESXi column.

I made this version to discover discrepancies in LUN assignments when using zoning on the SAN.

&lt;code&gt;
param(
    [string]$ClusterName
)

$csvName= &quot;.\$($ClusterName)-$(Get-Date -Format &#039;yyyy-MM-dd-hh-mm&#039;)-LUN.csv&quot;

$rndNum = Get-Random -Maximum 99999

$LunInfoDef = @&quot;
	public string ClusterName;
	public string CanonicalName;
	public string UsedBy;
	public string DSC;
	public string SizeGB;
&quot;@
$LunInfoDef = &quot;public struct LunInfo&quot; + $rndNum + &quot;{`n&quot; + $LunInfoDef

$esxServers = Get-Cluster $ClusterName &#124; Get-VMHost &#124; Sort-Object -Property Name
$esxServers &#124; %{
	$LunInfoDef += (&quot;`n`tpublic string &quot; + ($_.Name.Split(&quot;.&quot;)[0]) + &quot;;&quot;)
}
$LunInfoDef += &quot;`n}&quot;

Add-Type -Language CsharpVersion3 -TypeDefinition $LunInfoDef

$scsiTab = @{}
$esxServers &#124; %{
	$esxImpl = $_

# $scsiTab layout
# Key: &lt;ESX-hostname-1st-qualifier&gt;#&lt;canonicalname-2nd-qualifier&gt;
# Value: 
#	1) canonicalname
#   2) datastorename or VM/harddiskname
#   3) capacity (GB)
#   4) LunId
#   5) datastoreclustername
#

# Get SCSI LUNs
    if(([Version]$esxImpl.Version).Major -lt 6){
      $esxImpl &#124; Get-ScsiLun &#124; where {$_.LunType -eq &quot;Disk&quot;} &#124; %{
      
      	$key = $esxImpl.Name.Split(&quot;.&quot;)[0] + &quot;#&quot; + $_.CanonicalName.Split(&quot;.&quot;)[1]
      	if(!$scsiTab.ContainsKey($key)){
      		$lunId = $_.RuntimeName.Split(&#039;L&#039;)[1]
      		$scsiTab[$key] = $_.CanonicalName,&quot;&quot;,$_.CapacityGB,$lunId,&quot;&quot;
      	}
      }
    }
    Else{
      $esxImpl.ExtensionData.Config.StorageDevice.ScsiLun &#124; Where-Object{$_.LunType -eq &#039;disk&#039;} &#124;%{
          $key = $esxImpl.Name.Split(&quot;.&quot;)[0] + &quot;#&quot; + $_.CanonicalName.Split(&quot;.&quot;)[1]
          $capacityGB = $_.Capacity.Block * $_.Capacity.BlockSize / 1GB
          $lunUuid = $_.Uuid
          $lun = $esxImpl.ExtensionData.Config.StorageDevice.MultipathInfo.Lun &#124; Where-Object{$_.Id -eq $lunUuid}
          $lunId = $lun.Path[0].Name.Split(&#039;L&#039;)[1]
          $scsiTab[$key] = $_.CanonicalName,&quot;&quot;,$capacityGB,$lunId,&quot;&quot;
      }
    }

# Get the VMFS datastores
	$esxImpl &#124; Get-Datastore &#124; Where-Object {$_.Type -eq &quot;VMFS&quot;} &#124; Get-View &#124; %{
		$dsName = $_.Name
        $dscName = &#039;&#039;
        if($_.Parent.Type -eq &#039;StoragePod&#039;){
            $dscName = Get-View -Id $_.Parent -Property Name -Server $esxImpl.Uid.Split(&#039;@&#039;)[1].Split(&#039;:&#039;)[0] &#124; Select -ExpandProperty Name
        }
		$_.Info.Vmfs.Extent &#124; %{
			$key = $esxImpl.Name.Split(&quot;.&quot;)[0] + &quot;#&quot; + $_.DiskName.Split(&quot;.&quot;)[1]
			$scsiTab[$key][1] = $dsName
            $scsiTab[$key][4] = $dscName
		}
	}
}

# Get the RDM disks
Get-Cluster $ClusterName &#124; Get-VM &#124; Get-View &#124; %{
	$vm = $_
	$vm.Config.Hardware.Device &#124; Where-Object {$_.gettype().Name -eq &quot;VirtualDisk&quot;} &#124; %{
		if($_.Backing.PSObject.Properties[&#039;CompatibilityMode&#039;] -and &quot;physicalMode&quot;,&quot;virtualmode&quot; -contains $_.Backing.CompatibilityMode){
			$disk = $_.Backing.LunUuid.Substring(10,32)
			$key = (Get-View $vm.Runtime.Host -Server $esxImpl.Uid.Split(&#039;@&#039;)[1].Split(&#039;:&#039;)[0]).Name.Split(&quot;.&quot;)[0] + &quot;#&quot; + $disk
			$scsiTab[$key][1] = $vm.Name + &quot;/&quot; + $_.DeviceInfo.Label
		}
	}
}

$scsiTab.GetEnumerator() &#124; Group-Object -Property {$_.Key.Split(&quot;#&quot;)[1]} &#124; %{
	$lun = New-Object (&quot;LunInfo&quot; + $rndNum)
	$lun.ClusterName = $ClusterName
	$_.Group &#124; %{
		$esxName = $_.Key.Split(&quot;#&quot;)[0]
		$lun.$esxName = $_.Value[3]
		if(!$lun.CanonicalName){$lun.CanonicalName = $_.Value[0]}
		if(!$lun.UsedBy){$lun.UsedBy = $_.Value[1]}
		if(!$lun.SizeGB){$lun.SizeGB = [math]::Round($_.Value[2],0)}
        $lun.DSC = $_.Value[4]
	}
	$lun
}
&lt;/code&gt;]]></description>
			<content:encoded><![CDATA[<p>Hi David,<br />
You can try the version below.<br />
Instead of &#8216;OK&#8217; it shows the LUNid in each ESXi column.</p>
<p>I made this version to discover discrepancies in LUN assignments when using zoning on the SAN.</p>
<p><code><br />
param(<br />
    [string]$ClusterName<br />
)</p>
<p>$csvName= ".\$($ClusterName)-$(Get-Date -Format 'yyyy-MM-dd-hh-mm')-LUN.csv"</p>
<p>$rndNum = Get-Random -Maximum 99999</p>
<p>$LunInfoDef = @"<br />
	public string ClusterName;<br />
	public string CanonicalName;<br />
	public string UsedBy;<br />
	public string DSC;<br />
	public string SizeGB;<br />
"@<br />
$LunInfoDef = "public struct LunInfo" + $rndNum + "{</code><code>n" + $LunInfoDef</p>
<p>$esxServers = Get-Cluster $ClusterName | Get-VMHost | Sort-Object -Property Name<br />
$esxServers | %{<br />
	$LunInfoDef += ("</code>n<code>tpublic string " + ($_.Name.Split(".")[0]) + ";")<br />
}<br />
$LunInfoDef += "</code>n}"</p>
<p>Add-Type -Language CsharpVersion3 -TypeDefinition $LunInfoDef</p>
<p>$scsiTab = @{}<br />
$esxServers | %{<br />
	$esxImpl = $_</p>
<p># $scsiTab layout<br />
# Key: <ESX-hostname-1st-qualifier>#<canonicalname-2nd-qualifier><br />
# Value:<br />
#	1) canonicalname<br />
#   2) datastorename or VM/harddiskname<br />
#   3) capacity (GB)<br />
#   4) LunId<br />
#   5) datastoreclustername<br />
#</p>
<p># Get SCSI LUNs<br />
    if(([Version]$esxImpl.Version).Major -lt 6){<br />
      $esxImpl | Get-ScsiLun | where {$_.LunType -eq "Disk"} | %{</p>
<p>      	$key = $esxImpl.Name.Split(".")[0] + "#" + $_.CanonicalName.Split(".")[1]<br />
      	if(!$scsiTab.ContainsKey($key)){<br />
      		$lunId = $_.RuntimeName.Split('L')[1]<br />
      		$scsiTab[$key] = $_.CanonicalName,"",$_.CapacityGB,$lunId,""<br />
      	}<br />
      }<br />
    }<br />
    Else{<br />
      $esxImpl.ExtensionData.Config.StorageDevice.ScsiLun | Where-Object{$_.LunType -eq 'disk'} |%{<br />
          $key = $esxImpl.Name.Split(".")[0] + "#" + $_.CanonicalName.Split(".")[1]<br />
          $capacityGB = $_.Capacity.Block * $_.Capacity.BlockSize / 1GB<br />
          $lunUuid = $_.Uuid<br />
          $lun = $esxImpl.ExtensionData.Config.StorageDevice.MultipathInfo.Lun | Where-Object{$_.Id -eq $lunUuid}<br />
          $lunId = $lun.Path[0].Name.Split('L')[1]<br />
          $scsiTab[$key] = $_.CanonicalName,"",$capacityGB,$lunId,""<br />
      }<br />
    }</p>
<p># Get the VMFS datastores<br />
	$esxImpl | Get-Datastore | Where-Object {$_.Type -eq "VMFS"} | Get-View | %{<br />
		$dsName = $_.Name<br />
        $dscName = ''<br />
        if($_.Parent.Type -eq 'StoragePod'){<br />
            $dscName = Get-View -Id $_.Parent -Property Name -Server $esxImpl.Uid.Split('@')[1].Split(':')[0] | Select -ExpandProperty Name<br />
        }<br />
		$_.Info.Vmfs.Extent | %{<br />
			$key = $esxImpl.Name.Split(".")[0] + "#" + $_.DiskName.Split(".")[1]<br />
			$scsiTab[$key][1] = $dsName<br />
            $scsiTab[$key][4] = $dscName<br />
		}<br />
	}<br />
}</p>
<p># Get the RDM disks<br />
Get-Cluster $ClusterName | Get-VM | Get-View | %{<br />
	$vm = $_<br />
	$vm.Config.Hardware.Device | Where-Object {$_.gettype().Name -eq "VirtualDisk"} | %{<br />
		if($_.Backing.PSObject.Properties['CompatibilityMode'] -and "physicalMode","virtualmode" -contains $_.Backing.CompatibilityMode){<br />
			$disk = $_.Backing.LunUuid.Substring(10,32)<br />
			$key = (Get-View $vm.Runtime.Host -Server $esxImpl.Uid.Split('@')[1].Split(':')[0]).Name.Split(".")[0] + "#" + $disk<br />
			$scsiTab[$key][1] = $vm.Name + "/" + $_.DeviceInfo.Label<br />
		}<br />
	}<br />
}</p>
<p>$scsiTab.GetEnumerator() | Group-Object -Property {$_.Key.Split("#")[1]} | %{<br />
	$lun = New-Object ("LunInfo" + $rndNum)<br />
	$lun.ClusterName = $ClusterName<br />
	$_.Group | %{<br />
		$esxName = $_.Key.Split("#")[0]<br />
		$lun.$esxName = $_.Value[3]<br />
		if(!$lun.CanonicalName){$lun.CanonicalName = $_.Value[0]}<br />
		if(!$lun.UsedBy){$lun.UsedBy = $_.Value[1]}<br />
		if(!$lun.SizeGB){$lun.SizeGB = [math]::Round($_.Value[2],0)}<br />
        $lun.DSC = $_.Value[4]<br />
	}<br />
	$lun<br />
}<br />
</canonicalname-2nd-qualifier></p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: David		</title>
		<link>https://www.lucd.info/2010/04/09/lun-report-datastores-rdms-and-node-visibility/#comment-4761</link>

		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Fri, 20 Dec 2019 12:46:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.lucd.info/?p=2080#comment-4761</guid>

					<description><![CDATA[Hi LucD
Nice Script thank you very much

I would like to add the Lun Number for each NAA.* found in the report with this command
$esxcli.storage.core.path.list($_.DeviceName) &#124; %{new-object PSObject -Property @{LunId =&quot;L&quot;+$_.Lun}}
if you have an idea 
Thanks

David]]></description>
			<content:encoded><![CDATA[<p>Hi LucD<br />
Nice Script thank you very much</p>
<p>I would like to add the Lun Number for each NAA.* found in the report with this command<br />
$esxcli.storage.core.path.list($_.DeviceName) | %{new-object PSObject -Property @{LunId =&#8221;L&#8221;+$_.Lun}}<br />
if you have an idea<br />
Thanks</p>
<p>David</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Joseph		</title>
		<link>https://www.lucd.info/2010/04/09/lun-report-datastores-rdms-and-node-visibility/#comment-4598</link>

		<dc:creator><![CDATA[Joseph]]></dc:creator>
		<pubDate>Wed, 17 Apr 2019 15:06:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.lucd.info/?p=2080#comment-4598</guid>

					<description><![CDATA[I use these script alot, LUCD, is there a way to add LUN ID to map the the naa ? that would help alot

Thanks]]></description>
			<content:encoded><![CDATA[<p>I use these script alot, LUCD, is there a way to add LUN ID to map the the naa ? that would help alot</p>
<p>Thanks</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Vechiatto		</title>
		<link>https://www.lucd.info/2010/04/09/lun-report-datastores-rdms-and-node-visibility/#comment-4226</link>

		<dc:creator><![CDATA[Vechiatto]]></dc:creator>
		<pubDate>Mon, 30 Jan 2017 20:04:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.lucd.info/?p=2080#comment-4226</guid>

					<description><![CDATA[How could I list all the clusters in a single report?]]></description>
			<content:encoded><![CDATA[<p>How could I list all the clusters in a single report?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: LucD		</title>
		<link>https://www.lucd.info/2010/04/09/lun-report-datastores-rdms-and-node-visibility/#comment-3857</link>

		<dc:creator><![CDATA[LucD]]></dc:creator>
		<pubDate>Mon, 25 Apr 2016 17:24:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.lucd.info/?p=2080#comment-3857</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.lucd.info/2010/04/09/lun-report-datastores-rdms-and-node-visibility/#comment-3855&quot;&gt;Aaron&lt;/a&gt;.

Thanks for providing the fix.]]></description>
			<content:encoded><![CDATA[<p>Thanks for providing the fix.</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
