i am having problem with UserVars.ESXiShellTimeOut
$Shelltimeout
= Get-VMHost | Select Name, @{N="settings";E={(Get-VMHostAdvancedConfiguration -vmhost $vmh -name UserVars.ESXiShellTimeOut).values}}$Shelltimeout.settings is blank.
but
Get-VMHost | Get-VMHostAdvancedConfiguration -Name uservars.esxishelltimeout
works just fine
Name Value
---- -----
UserVars.ESXiShellTimeOut 0
UserVars.ESXiShellTimeOut 12000
Esxi 5.0 version..
thanks for all the help!
Try this updated version of the script
$HostData = @() $vmhs = Get-VMHost
foreach($vmh in $vmhs){ $myItem = "" | Select VC , Host , Version, Shelltimeout
$myItem.Host = $vmh.Name
$myItem.VC = $defaultviserver.Name
$myItem.Version = $vmh.Version
$myItem.Shelltimeout = Get-VMHostAdvancedConfiguration -vmhost $vmh -name UserVars.ESXiShellTimeOut | Select -ExpandProperty Values
$HostData += $myItem
} $HostData
That should give you the values you are after
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
In the command that is not working should you replace $vmh with $_
You have to specify the variable for the object in the pipeline instead of $vmh
Something like this
Get-VMHost | Select Name, @{N="settings";E={(Get-VMHostAdvancedConfiguration -vmhost $_ -name UserVars.ESXiShellTimeOut).values}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
thanks. this helped
$Shelltimeout = Get-VMHost | Select Name, @{N="settings";E={(Get-VMHostAdvancedConfiguration -vmhost $_ -name UserVars.ESXiShellTimeOut).values}}
but when i do this in a script
$myItem.Shelltimeout = $Shelltimeout.settings , its blank.
when i run this on powershell, get this..
PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> write-ho
st $shelltimeout
@{Name=xxx1; settings=0} @{Name=xxx2; settings=12000}
thanks
Sorry , but I'm not following you here.
Where does the $myItem variable come from ?
The objects that come out of the 2 piped cmdlets was stored in the variable $Shelltimeout, not in $myItem.Shelltimeout.
From the code you've shown us the variable $myItem is empty, and hence that explains the blank result.
From the command prompt you do a Write-Host of the variable $Shelltimeout, and that displays the object that was returned by the two pipelined cmdlets. Note that Select-Object returns by default again a hash table, hence the formatting of the output you are seeing.
Perhaps you could show us the complete script you are using, that would perhaps make things a bit clearer.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
$Shelltimeout = Get-VMHost | Select Name, @{N="settings";E={(Get-VMHostAdvancedConfiguration -vmhost $_ -name UserVars.ESXiShellTimeOut).values}}
$myItem.Shelltimeout = $Shelltimeout.settings
this doesnt seem to work. i keep getting blank in the csv file. On the Powershell connamd line, if i do a write-host $shelltimeout[0].settings, i get an output, but $Shelltimeout.settings is blank. i am using this within a foreach loop
foreach
($vmh in $vmhs)
{
$myItem = "" | Select VC , Host , Shelltimeout
$myItem.Host = $vmh.Name
$myItem.VC = $vc
$myItem.Version = $vmh.Version
Connect-VIServer $vmh.Name -Credential $rcred
$Shelltimeout= Get-VMHost | Select Name, @{N="settings";E={(Get-VMHostAdvancedConfiguration -vmhost $_ -name UserVars.ESXiShellTimeOut).values}}
$myItem.Shelltimeout = $Shellto.settings
Disconnect-VIServer -Server * -Confirm:$false
$HostData += $myItem
}
}
how do i specify the arraynumber?
thanks in advance for you help!!
Try this updated version of the script
$HostData = @() $vmhs = Get-VMHost
foreach($vmh in $vmhs){ $myItem = "" | Select VC , Host , Version, Shelltimeout
$myItem.Host = $vmh.Name
$myItem.VC = $defaultviserver.Name
$myItem.Version = $vmh.Version
$myItem.Shelltimeout = Get-VMHostAdvancedConfiguration -vmhost $vmh -name UserVars.ESXiShellTimeOut | Select -ExpandProperty Values
$HostData += $myItem
} $HostData
That should give you the values you are after
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
thanks. thats Works.