<?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: The making of a New-VIProperty called lunID	</title>
	<atom:link href="https://www.lucd.info/2011/07/26/the-making-of-a-new-viproperty-called-lunid/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.lucd.info/2011/07/26/the-making-of-a-new-viproperty-called-lunid/</link>
	<description>My PowerShell ramblings</description>
	<lastBuildDate>Wed, 06 Feb 2013 15:48:12 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</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: Arvinth		</title>
		<link>https://www.lucd.info/2011/07/26/the-making-of-a-new-viproperty-called-lunid/#comment-2002</link>

		<dc:creator><![CDATA[Arvinth]]></dc:creator>
		<pubDate>Wed, 06 Feb 2013 15:48:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.lucd.info/?p=3452#comment-2002</guid>

					<description><![CDATA[Hello Luc,

Need your help to sort out the below requirement

I am using a seperate script for extracting RDM attached VM’s &#038; seperate one for extracting LUN id for the respective devices
I used to edit this scripts based on requirment , whether to run at VC level or host or cluster.

But now i have got a requirement to combine both the scripts
to list the below details using single script 

VMName,VMHost,HDDeviceName,HDMode,HDsize,LunId

I have attached the scripts below , Request your help in getting as a single output

————————————————————————————————————-

$report = @()
$vms = Get-VM &#124; Get-View
foreach($vm in $vms){
foreach($dev in $vm.Config.Hardware.Device){
if(($dev.gettype()).Name -eq “VirtualDisk”){
if(($dev.Backing.CompatibilityMode -eq “physicalMode”) -or
($dev.Backing.CompatibilityMode -eq “virtualMode”)){
$row = “” &#124; select VMName, VMHost, HDDeviceName, HDFileName, HDMode, HDsize
$row.VMName = $vm.Name
$row.VMHost = (Get-View $vm.Runtime.Host).Name
$row.HDDeviceName = $dev.Backing.DeviceName
$row.HDFileName = $dev.Backing.FileName
$row.HDMode = $dev.Backing.CompatibilityMode
$row.HDSize = $dev.CapacityInKB
$report += $row
}
}
}
}
$report

——————————————————————————————————————-
To get the LUN id

Get-VM &#124; `
Get-HardDisk &#124; `
Where-Object {$_.DiskType -eq “RawPhysical”} &#124; `
Select-Object -Property @{N=”VM”;E={$_.Parent}},
@{N=”HardDisk”;E={$_.Name}},
@{N=”Lun”;E={
$HardDisk = $_
$lun = Get-VMHost -VM $_.Parent &#124; `
Get-ScsiLun -LunType Disk &#124; `
Where-Object {$_.CanonicalName -eq $HardDisk.ScsiCanonicalName}
[int](Select-String “:L(?\d+)$” `
-InputObject $lun.RuntimeName).Matches[0].Groups[&#039;lunID&#039;].Value
}}
—————————————————————————————————————-]]></description>
			<content:encoded><![CDATA[<p>Hello Luc,</p>
<p>Need your help to sort out the below requirement</p>
<p>I am using a seperate script for extracting RDM attached VM’s &amp; seperate one for extracting LUN id for the respective devices<br />
I used to edit this scripts based on requirment , whether to run at VC level or host or cluster.</p>
<p>But now i have got a requirement to combine both the scripts<br />
to list the below details using single script </p>
<p>VMName,VMHost,HDDeviceName,HDMode,HDsize,LunId</p>
<p>I have attached the scripts below , Request your help in getting as a single output</p>
<p>————————————————————————————————————-</p>
<p>$report = @()<br />
$vms = Get-VM | Get-View<br />
foreach($vm in $vms){<br />
foreach($dev in $vm.Config.Hardware.Device){<br />
if(($dev.gettype()).Name -eq “VirtualDisk”){<br />
if(($dev.Backing.CompatibilityMode -eq “physicalMode”) -or<br />
($dev.Backing.CompatibilityMode -eq “virtualMode”)){<br />
$row = “” | select VMName, VMHost, HDDeviceName, HDFileName, HDMode, HDsize<br />
$row.VMName = $vm.Name<br />
$row.VMHost = (Get-View $vm.Runtime.Host).Name<br />
$row.HDDeviceName = $dev.Backing.DeviceName<br />
$row.HDFileName = $dev.Backing.FileName<br />
$row.HDMode = $dev.Backing.CompatibilityMode<br />
$row.HDSize = $dev.CapacityInKB<br />
$report += $row<br />
}<br />
}<br />
}<br />
}<br />
$report</p>
<p>——————————————————————————————————————-<br />
To get the LUN id</p>
<p>Get-VM | <code><br />
Get-HardDisk | </code><br />
Where-Object {$_.DiskType -eq “RawPhysical”} | <code><br />
Select-Object -Property @{N=”VM”;E={$_.Parent}},<br />
@{N=”HardDisk”;E={$_.Name}},<br />
@{N=”Lun”;E={<br />
$HardDisk = $_<br />
$lun = Get-VMHost -VM $_.Parent | </code><br />
Get-ScsiLun -LunType Disk | <code><br />
Where-Object {$_.CanonicalName -eq $HardDisk.ScsiCanonicalName}<br />
[int](Select-String “:L(?\d+)$” </code><br />
-InputObject $lun.RuntimeName).Matches[0].Groups[&#8216;lunID&#8217;].Value<br />
}}<br />
—————————————————————————————————————-</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Arvinth		</title>
		<link>https://www.lucd.info/2011/07/26/the-making-of-a-new-viproperty-called-lunid/#comment-1977</link>

		<dc:creator><![CDATA[Arvinth]]></dc:creator>
		<pubDate>Thu, 17 Jan 2013 16:31:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.lucd.info/?p=3452#comment-1977</guid>

					<description><![CDATA[Hey Luc, 

I am using a seperate script for extracting RDM attached VM&#039;s &#038; seperate one for extracting LUN id for the respective devices
I used to edit this scripts based on requirment , whether to run at VC level or host or cluster.

But now i have got a requirement to combine both the scripts
to list the below details using single script 

VMName,VMHost,HDDeviceName,HDMode,HDsize,LunId

I have attached the scripts below , Request your help in getting as a single output

-------------------------------------------------------------------------------------------------------------

$report = @()
$vms = Get-VM  &#124; Get-View
foreach($vm in $vms){
  foreach($dev in $vm.Config.Hardware.Device){
    if(($dev.gettype()).Name -eq &quot;VirtualDisk&quot;){
       if(($dev.Backing.CompatibilityMode -eq &quot;physicalMode&quot;) -or 
          ($dev.Backing.CompatibilityMode -eq &quot;virtualMode&quot;)){
         $row = &quot;&quot; &#124; select VMName, VMHost, HDDeviceName, HDFileName, HDMode, HDsize
          $row.VMName = $vm.Name
         $row.VMHost = (Get-View $vm.Runtime.Host).Name
         $row.HDDeviceName = $dev.Backing.DeviceName
         $row.HDFileName = $dev.Backing.FileName
         $row.HDMode = $dev.Backing.CompatibilityMode
           $row.HDSize = $dev.CapacityInKB
         $report += $row
       }
     }
  }
}
$report

-------------------------------------------------------------------------------------------------------------------
To get the LUN id

Get-VM &#124; `
Get-HardDisk &#124; `
Where-Object {$_.DiskType -eq &quot;RawPhysical&quot;} &#124; `
Select-Object -Property @{N=&quot;VM&quot;;E={$_.Parent}},
  @{N=&quot;HardDisk&quot;;E={$_.Name}},
  @{N=&quot;Lun&quot;;E={
    $HardDisk = $_
    $lun = Get-VMHost -VM $_.Parent &#124; `
      Get-ScsiLun -LunType Disk &#124; `
      Where-Object {$_.CanonicalName -eq $HardDisk.ScsiCanonicalName}
    [int](Select-String &quot;:L(?\d+)$&quot; `
        -InputObject $lun.RuntimeName).Matches[0].Groups[&#039;lunID&#039;].Value
  }}
----------------------------------------------------------------------------------------------------------------]]></description>
			<content:encoded><![CDATA[<p>Hey Luc, </p>
<p>I am using a seperate script for extracting RDM attached VM&#8217;s &amp; seperate one for extracting LUN id for the respective devices<br />
I used to edit this scripts based on requirment , whether to run at VC level or host or cluster.</p>
<p>But now i have got a requirement to combine both the scripts<br />
to list the below details using single script </p>
<p>VMName,VMHost,HDDeviceName,HDMode,HDsize,LunId</p>
<p>I have attached the scripts below , Request your help in getting as a single output</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>$report = @()<br />
$vms = Get-VM  | Get-View<br />
foreach($vm in $vms){<br />
  foreach($dev in $vm.Config.Hardware.Device){<br />
    if(($dev.gettype()).Name -eq &#8220;VirtualDisk&#8221;){<br />
       if(($dev.Backing.CompatibilityMode -eq &#8220;physicalMode&#8221;) -or<br />
          ($dev.Backing.CompatibilityMode -eq &#8220;virtualMode&#8221;)){<br />
         $row = &#8220;&#8221; | select VMName, VMHost, HDDeviceName, HDFileName, HDMode, HDsize<br />
          $row.VMName = $vm.Name<br />
         $row.VMHost = (Get-View $vm.Runtime.Host).Name<br />
         $row.HDDeviceName = $dev.Backing.DeviceName<br />
         $row.HDFileName = $dev.Backing.FileName<br />
         $row.HDMode = $dev.Backing.CompatibilityMode<br />
           $row.HDSize = $dev.CapacityInKB<br />
         $report += $row<br />
       }<br />
     }<br />
  }<br />
}<br />
$report</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
To get the LUN id</p>
<p>Get-VM | <code><br />
Get-HardDisk | </code><br />
Where-Object {$_.DiskType -eq &#8220;RawPhysical&#8221;} | <code><br />
Select-Object -Property @{N="VM";E={$_.Parent}},<br />
  @{N="HardDisk";E={$_.Name}},<br />
  @{N="Lun";E={<br />
    $HardDisk = $_<br />
    $lun = Get-VMHost -VM $_.Parent | </code><br />
      Get-ScsiLun -LunType Disk | <code><br />
      Where-Object {$_.CanonicalName -eq $HardDisk.ScsiCanonicalName}<br />
    [int](Select-String ":L(?\d+)$" </code><br />
        -InputObject $lun.RuntimeName).Matches[0].Groups[&#8216;lunID&#8217;].Value<br />
  }}<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: André		</title>
		<link>https://www.lucd.info/2011/07/26/the-making-of-a-new-viproperty-called-lunid/#comment-1901</link>

		<dc:creator><![CDATA[André]]></dc:creator>
		<pubDate>Tue, 18 Dec 2012 21:23:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.lucd.info/?p=3452#comment-1901</guid>

					<description><![CDATA[Thank LucD, this note helped me a lot.]]></description>
			<content:encoded><![CDATA[<p>Thank LucD, this note helped me a lot.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: LucD		</title>
		<link>https://www.lucd.info/2011/07/26/the-making-of-a-new-viproperty-called-lunid/#comment-1488</link>

		<dc:creator><![CDATA[LucD]]></dc:creator>
		<pubDate>Thu, 15 Mar 2012 12:32:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.lucd.info/?p=3452#comment-1488</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.lucd.info/2011/07/26/the-making-of-a-new-viproperty-called-lunid/#comment-1487&quot;&gt;Alessandro&lt;/a&gt;.

@Alessandro, there a couple of such script around.
The one from Glenn, one of my co-authors, is called &lt;a href=&quot;http://get-admin.com/blog/scripting/powershell-scripting/powercli-balance-lun-paths-for-a-cluster/&quot; rel=&quot;nofollow ugc&quot;&gt;PowerCLI: Balance LUN paths for a Cluster&lt;/a&gt;. It&#039;s not exactly how you want to organise the load balance, but it should be not too difficult to adapt Glenn&#039;s script.
There is another script that us quite good, it&#039;s Rob&#039;s script from the &lt;a href=&quot;https://communities.vmware.com/message/999336#999336&quot; rel=&quot;nofollow ugc&quot;&gt;storage-path script&lt;/a&gt; thread on the PowerCLI Community.]]></description>
			<content:encoded><![CDATA[<p>@Alessandro, there a couple of such script around.<br />
The one from Glenn, one of my co-authors, is called <a href="http://get-admin.com/blog/scripting/powershell-scripting/powercli-balance-lun-paths-for-a-cluster/" rel="nofollow ugc">PowerCLI: Balance LUN paths for a Cluster</a>. It&#8217;s not exactly how you want to organise the load balance, but it should be not too difficult to adapt Glenn&#8217;s script.<br />
There is another script that us quite good, it&#8217;s Rob&#8217;s script from the <a href="https://communities.vmware.com/message/999336#999336" rel="nofollow ugc">storage-path script</a> thread on the PowerCLI Community.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Alessandro		</title>
		<link>https://www.lucd.info/2011/07/26/the-making-of-a-new-viproperty-called-lunid/#comment-1487</link>

		<dc:creator><![CDATA[Alessandro]]></dc:creator>
		<pubDate>Wed, 14 Mar 2012 18:18:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.lucd.info/?p=3452#comment-1487</guid>

					<description><![CDATA[Hi there, thank you for the script. I would like to find a way to balance the preferred path on the odd/even lunID. I must say I am a novice of powershell... Does someone have something ready?
Thank you in advance.]]></description>
			<content:encoded><![CDATA[<p>Hi there, thank you for the script. I would like to find a way to balance the preferred path on the odd/even lunID. I must say I am a novice of powershell&#8230; Does someone have something ready?<br />
Thank you in advance.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Suhail		</title>
		<link>https://www.lucd.info/2011/07/26/the-making-of-a-new-viproperty-called-lunid/#comment-1294</link>

		<dc:creator><![CDATA[Suhail]]></dc:creator>
		<pubDate>Thu, 17 Nov 2011 11:49:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.lucd.info/?p=3452#comment-1294</guid>

					<description><![CDATA[Thanks for sharing some great information.

I am trying to get the LUN ids via your script but the output is only CanonicalName, the lunID column is blank.

There is no error when i run the script.

Could you please help me.

Thanks,
Suhail.]]></description>
			<content:encoded><![CDATA[<p>Thanks for sharing some great information.</p>
<p>I am trying to get the LUN ids via your script but the output is only CanonicalName, the lunID column is blank.</p>
<p>There is no error when i run the script.</p>
<p>Could you please help me.</p>
<p>Thanks,<br />
Suhail.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: ranjit		</title>
		<link>https://www.lucd.info/2011/07/26/the-making-of-a-new-viproperty-called-lunid/#comment-1195</link>

		<dc:creator><![CDATA[ranjit]]></dc:creator>
		<pubDate>Thu, 25 Aug 2011 12:20:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.lucd.info/?p=3452#comment-1195</guid>

					<description><![CDATA[&lt;a href=&quot;#comment-1192&quot; rel=&quot;nofollow&quot;&gt;@LucD  &lt;/a&gt; 

LucD ,thanks for your reply.
Get-VMHost $esxName &#124; Get-ScsiLun   when i run ,..i get following output
CanonicalN ConsoleDeviceName              LunType    CapacityMB MultipathPolicy
ame
---------- -----------------              -------    ---------- ---------------
naa.600... /vmfs/devices/disks/naa.600... disk          1228800 Fixed

yesterday i tried to much on this but not able to get lunID ,if i put lunID in select then i get error but it displays information of other selected fileds.

my powercli version is:- (get-powercliversion)
PowerCLI Version
----------------
   VMware vSphere PowerCLI 4.1 U1 build 332441
---------------
Snapin Versions
---------------
   VMWare vSphere PowerCLI 4.1 U1 build 332441

------------------------------------------------------------
currently i am connecting to esx from powercli and then running the script ..can run this script for vcenter..so that i will get information for all esx server and if i could get esx server name in first coloumn then it will be great.

thanks in advance.]]></description>
			<content:encoded><![CDATA[<p><a href="#comment-1192" rel="nofollow">@LucD  </a> </p>
<p>LucD ,thanks for your reply.<br />
Get-VMHost $esxName | Get-ScsiLun   when i run ,..i get following output<br />
CanonicalN ConsoleDeviceName              LunType    CapacityMB MultipathPolicy<br />
ame<br />
&#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;&#8212;&#8211;              &#8212;&#8212;-    &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;&#8212;<br />
naa.600&#8230; /vmfs/devices/disks/naa.600&#8230; disk          1228800 Fixed</p>
<p>yesterday i tried to much on this but not able to get lunID ,if i put lunID in select then i get error but it displays information of other selected fileds.</p>
<p>my powercli version is:- (get-powercliversion)<br />
PowerCLI Version<br />
&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
   VMware vSphere PowerCLI 4.1 U1 build 332441<br />
&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Snapin Versions<br />
&#8212;&#8212;&#8212;&#8212;&#8212;<br />
   VMWare vSphere PowerCLI 4.1 U1 build 332441</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
currently i am connecting to esx from powercli and then running the script ..can run this script for vcenter..so that i will get information for all esx server and if i could get esx server name in first coloumn then it will be great.</p>
<p>thanks in advance.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: LucD		</title>
		<link>https://www.lucd.info/2011/07/26/the-making-of-a-new-viproperty-called-lunid/#comment-1192</link>

		<dc:creator><![CDATA[LucD]]></dc:creator>
		<pubDate>Wed, 24 Aug 2011 18:19:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.lucd.info/?p=3452#comment-1192</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.lucd.info/2011/07/26/the-making-of-a-new-viproperty-called-lunid/#comment-1189&quot;&gt;ranjit&lt;/a&gt;.

@Ranjit, can you check if the following returns anything ?
&lt;code&gt;
$esxName = &quot;esx04&quot; 
Get-VMHost $esxName &#124; Get-ScsiLun 
&lt;/code&gt;]]></description>
			<content:encoded><![CDATA[<p>@Ranjit, can you check if the following returns anything ?<br />
<code><br />
$esxName = "esx04"<br />
Get-VMHost $esxName | Get-ScsiLun<br />
</code></p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: ranjit		</title>
		<link>https://www.lucd.info/2011/07/26/the-making-of-a-new-viproperty-called-lunid/#comment-1189</link>

		<dc:creator><![CDATA[ranjit]]></dc:creator>
		<pubDate>Wed, 24 Aug 2011 13:42:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.lucd.info/?p=3452#comment-1189</guid>

					<description><![CDATA[New-VIProperty -Name lunID -ObjectType ScsiLun -Value {
	param($lun)

	[int](Select-String &quot;:L(?\d+)$&quot;`
		-InputObject $lun.RuntimeName).Matches[0].Groups[&#039;lunID&#039;].Value
}  -Force &#124; Out-Null

$esxName = &quot;esx04&quot;
Get-VMHost $esxName &#124; Get-ScsiLun &#124; Select CanonicalName, LunType, CapacityMB, MultipathPolicy, lunID

i have saved above script as .ps1 but getting error
Select-Object : Cannot index into a null array.
At C:\scripts\LunNumber.ps1:15 char:43
+ Get-VMHost $esxName &#124; Get-ScsiLun &#124; Select  &#060;&#060;&#060;&#060; CanonicalName, LunType, CapacityMB, MultipathPol
icy, lunID

could you please help ..can i get esx server name in first coloumn it will be ver usefull.]]></description>
			<content:encoded><![CDATA[<p>New-VIProperty -Name lunID -ObjectType ScsiLun -Value {<br />
	param($lun)</p>
<p>	[int](Select-String &#8220;:L(?\d+)$&#8221;`<br />
		-InputObject $lun.RuntimeName).Matches[0].Groups[&#8216;lunID&#8217;].Value<br />
}  -Force | Out-Null</p>
<p>$esxName = &#8220;esx04&#8221;<br />
Get-VMHost $esxName | Get-ScsiLun | Select CanonicalName, LunType, CapacityMB, MultipathPolicy, lunID</p>
<p>i have saved above script as .ps1 but getting error<br />
Select-Object : Cannot index into a null array.<br />
At C:\scripts\LunNumber.ps1:15 char:43<br />
+ Get-VMHost $esxName | Get-ScsiLun | Select  &lt;&lt;&lt;&lt; CanonicalName, LunType, CapacityMB, MultipathPol<br />
icy, lunID</p>
<p>could you please help ..can i get esx server name in first coloumn it will be ver usefull.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: LucD		</title>
		<link>https://www.lucd.info/2011/07/26/the-making-of-a-new-viproperty-called-lunid/#comment-1172</link>

		<dc:creator><![CDATA[LucD]]></dc:creator>
		<pubDate>Tue, 16 Aug 2011 09:00:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.lucd.info/?p=3452#comment-1172</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.lucd.info/2011/07/26/the-making-of-a-new-viproperty-called-lunid/#comment-1171&quot;&gt;Albert&lt;/a&gt;.

@Albert, everything is possibile ;-)
The following new property will display the DatastoreName.
&lt;code&gt;
New-VIProperty -Name lunDatastoreName -ObjectType ScsiLun -Value {
	param($lun)

	$ds = $lun.VMHost.ExtensionData.Datastore &#124; %{Get-View $_} &#124; `
		where {$_.Summary.Type -eq &quot;VMFS&quot; -and 
			($_.Info.Vmfs.Extent &#124; where {$_.DiskName -eq $lun.CanonicalName})}
	if($ds){
		$ds.Name
	}
} -Force &#124; Out-Null
&lt;/code&gt;
You can use it like this
&lt;code&gt;
Get-VMHost $esxName &#124; Get-ScsiLun &#124; Select CanonicalName, CapacityMB, lunID,lunDatastoreName
&lt;/code&gt;
Just one word of warning, this new property is very slow as you will notice.]]></description>
			<content:encoded><![CDATA[<p>@Albert, everything is possibile 😉<br />
The following new property will display the DatastoreName.<br />
<code><br />
New-VIProperty -Name lunDatastoreName -ObjectType ScsiLun -Value {<br />
	param($lun)</p>
<p>	$ds = $lun.VMHost.ExtensionData.Datastore | %{Get-View $_} | `<br />
		where {$_.Summary.Type -eq "VMFS" -and<br />
			($_.Info.Vmfs.Extent | where {$_.DiskName -eq $lun.CanonicalName})}<br />
	if($ds){<br />
		$ds.Name<br />
	}<br />
} -Force | Out-Null<br />
</code><br />
You can use it like this<br />
<code><br />
Get-VMHost $esxName | Get-ScsiLun | Select CanonicalName, CapacityMB, lunID,lunDatastoreName<br />
</code><br />
Just one word of warning, this new property is very slow as you will notice.</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
