Hi,
I want to extract lun details from all hosts connected to a particular vcenter server. I found the following article, however it talks about one cluster, what modification is needed to run at vcenter level without providing cluster name as a parameter
LUN report - datastore, RDM and node visibility - LucD notes
You could run the function against all clusters in your vCenter.
Something like this
Get-Cluster | %{
.\Cluster-LUN-List.ps1 $_.Name
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi,
I tried executing the script and got following error
The property 'ClusterName' cannot be found on this object. Verify that the
property exists and can be set.
At C:\TEMP\Cluster-LUN-List.ps1:61 char:2
+ $lun.ClusterName = $clusName
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
The property '129' cannot be found on this object. Verify that the property
exists and can be set.
At C:\TEMP\Cluster-LUN-List.ps1:64 char:3
+ $lun.$esxName = "ok"
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
The property 'CanonicalName' cannot be found on this object. Verify that the
property exists and can be set.
At C:\TEMP\Cluster-LUN-List.ps1:65 char:27
+ if(!$lun.CanonicalName){$lun.CanonicalName = $_.Value[0]}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
The property 'UsedBy' cannot be found on this object. Verify that the propert
exists and can be set.
At C:\TEMP\Cluster-LUN-List.ps1:66 char:20
+ if(!$lun.UsedBy){$lun.UsedBy = $_.Value[1]}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
The property 'SizeMB' cannot be found on this object. Verify that the propert
exists and can be set.
At C:\TEMP\Cluster-LUN-List.ps1:67 char:20
+ if(!$lun.SizeMB){$lun.SizeMB = $_.Value[2]}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
do I need any specific version or powercli to run this script ?
Regards,
Suresh
No, but it looks like the Add-Type didn't work.
Could you eventually attach the .ps1 file you are calling?
There might have been some copy/paste issues
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Ok, which PowerShell version are you suing?
Display the content of $PSVersionTable
Did you see the following as the first error?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
PowerCLI C:\TEMP> $PSVersionTable
Name Value
---- -----
PSVersion 4.0
WSManStackVersion 3.0
SerializationVersion 1.1.0.1
CLRVersion 4.0.30319.34014
BuildVersion 6.3.9600.16394
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion 2.2
Did you see the following as the first error?
I could not grab that info while running, can you let me know how can I redirect the error message to a file to check that please.
You can send the output to a text file.
Start-Transcript -Append -Path C:\Temp\output.txt
Get-Cluster | %{
.\Cluster-LUN-List.ps1 $_.Name 2>&1 | Write-Output
}
Stop-Transcript
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Attached output file
Looks like a funny character slipped in during the copy/paste of the code.
The following line seems to indicate that
Invalid token '129' in class, struct, or interface member declaration
Try with the attached .ps1 file instead
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Do you happen to have ESXi nodes that have an IP address as the hostname?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
No, we have only two hosts in the VC and none of them has IP as the hostname.
What does this return?
Get-Cluster -Name CLuster01 | Get-VMHost
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
It returns the IP address of the ESXi hosts, one thing I forgot to mention, the hosts are connected using IP to VC instead of hostname. Would that cause this issue ?
Yes, that is why we see the 129 error.
It takes that name,splits on the dot and takes the first qualifier, which is obviously 129.
Try the attached, slightly adapted version.
Also note that the machine where you run this needs .Net 3.5 to be installed (due to the Add-Type the script is using).
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hey LuCD,
The script is failing due to my hosts have a - in the name.
Add-Type -Language CsharpVersion3 -TypeDefinition $LunInfoDef
Its failing when it tries to run the add-type command. it doesnt like a - in the type definition. is there away around this issue?
PS C:\git> Add-Type -Language CsharpVersion3 -TypeDefinition $LunInfoDef
Add-Type : c:\Users\AppData\Local\Temp\1\bp1zm0ly.0.cs(6) : Invalid token '-' in class, struct, or interface member declaration
c:\Users\AppData\Local\Temp\1\bp1zm0ly.0.cs(5) : public string SizeMB;
c:\Users\AppData\Local\Temp\1\bp1zm0ly.0.cs(6) : >>> public string****-****;
c:\Users\AppData\Local\Temp\1\bp1zm0ly.0.cs(7) : public string*****-****;
At line:1 char:1
+ Add-Type -Language CsharpVersion3 -TypeDefinition $LunInfoDef -Ignore ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (Microsoft.Power...peCompilerError:AddTypeCompilerError) [Add-Type], Exception
+ FullyQualifiedErrorId : SOURCE_CODE_ERROR,Microsoft.PowerShell.Commands.AddTypeCommand
In the comments of my LUN Report – Datastore, RDM And Node Visibility post, there are a couple of solutions for that issue.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference