Hello-
You are not quite calling things correctly. There are two (2) distinct things that you need to do:
For item 0, you _must_ include the period and the space before the name of the file in which the function is defined. That action is what makes the function "Get-VNVMHostLogicalVolumeInfo" available in your PowerShell session. That is "dot-sourcing".
Then, for item 1, that is the function name, "Get-VNVMHostLogicalVolumeInfo", not the name of the function definition file (the .ps1 file). Until you do those two things, you will continue to get zero output. Do you follow?
Hello, chakoe-
At least one way to do it, if you have the CIM providers running in your ESXi instance for the hardware on which it is running, is to get such info from the resultant info. We at vNugglets.com wrote about doing so in our post, "VMHost Logical Drive Info from CIM Provider with PowerCLI".
Give that a look -- does that suit your need?
Hi,
your function looks good, but in my environment, it does nothing 😞
I created a .ps1-File, just copied your function into it, saved it under the same name you used and then tried to test it.
first of all, i used an connect-viserver...
then i started the script with the function in it and nothing happended. Just the prompt appears .
Hello, chakoe-
It sounds like you may not have yet _called_ the function, only defined it in your current PowerShell session. By pasting the function definition into a .ps1 file, and then dot-sourcing the .ps1 file, you define the function within the current PowerShell session.
The next step that you need to do after that is then actually call the function that you have defined in the session. So, altogether, it would look something like:
## dot-source the function definition file
. c:\temp\vNuggletsLogicalDriveFunction.ps1
## then, actually call the function
Get-VNVMHostLogicalVolumeInfo -VMHostName myvmhost0.dom.com
## or, call it with no parameters to get logical volume info for all VMHosts in the vCenter to which you are connected
Get-VNVMHostLogicalVolumeInfo
That should give some output like:
Name logicalVol ---- ---------- myvmhost0.dom.com Logical Volume 1 on HPSA1 : RAID 1 : 136GB : Disk 1,2,3
That work out for you?
hmmm no, sorry...
PS D:\VCenter-Skripte\Host-Operations> ./Get-VNVMHostLogicalVolumeInfo.ps1
PS D:\VCenter-Skripte\Host-Operations> ./Get-VNVMHostLogicalVolumeInfo.ps1 -VMHostName e998spwesx4001n.e998.intern
no Output... here´s the content of the ps1-File
<# .Description
Get logical volume info for HP VMHosts from StorageStatusInfo of their managed objects. Depends on CIM provider being installed and in good health (responsive and whatnot), presumably
Author: vNugglets.com -- Aug 2012
#>
function Get-VNVMHostLogicalVolumeInfo {
param(
## name of VMHost to check; if none, queries all hosts
[string]$VMHostName_str
) ## end param
## make the Get-View expression to invoke
$strGetViewExpr = 'Get-View -ViewType HostSystem -Property Name,Runtime.HealthSystemRuntime.HardwareStatusInfo.StorageStatusInfo'
if ($VMHostName_str) {$strGetViewExpr += " -Filter @{'Name' = '$VMHostName_str'}"}
Invoke-Expression $strGetViewExpr | Select name,
@{n="logicalVol";
e={($_.Runtime.HealthSystemRuntime.HardwareStatusInfo.StorageStatusInfo | `
?{$_.Name -like "Logical*"} | %{$_.Name}) -join ", "}}
} ## end function
Hello-
You are not quite calling things correctly. There are two (2) distinct things that you need to do:
For item 0, you _must_ include the period and the space before the name of the file in which the function is defined. That action is what makes the function "Get-VNVMHostLogicalVolumeInfo" available in your PowerShell session. That is "dot-sourcing".
Then, for item 1, that is the function name, "Get-VNVMHostLogicalVolumeInfo", not the name of the function definition file (the .ps1 file). Until you do those two things, you will continue to get zero output. Do you follow?