jakas
Contributor
Contributor

UserVars.ESXiShellTimeOut

Jump to solution

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!

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

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

View solution in original post

0 Kudos
7 Replies
RvdNieuwendijk
Leadership
Leadership

In the command that is not working should you replace $vmh with $_

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
LucD
Leadership
Leadership

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

0 Kudos
jakas
Contributor
Contributor

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

0 Kudos
LucD
Leadership
Leadership

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

0 Kudos
jakas
Contributor
Contributor

$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!!

0 Kudos
LucD
Leadership
Leadership

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

0 Kudos
jakas
Contributor
Contributor

thanks. thats Works.

0 Kudos