i use this command to set hostname
$esx = Get-VMHost
$hostnamearray = $esx.name.split(",")
$hostname = $hostnamearray[0]
$n='LOCAL'+ $hostnamearray
Get-VMHostNetwork -VMHost $esx | Set-VMHostNetwork -HostName $hostname
i get the hostname is:test192.168.50.180,i wan't set the hostname like test-50-180,help me please!
You could do something like this
$nameArr = @('test')
$nameArr += $esx.Name.split('.')[2..3]
Get-VMHostNetwork -VMHost $esx |
Set-VMHostNetwork -HostName ($nameArr -join '-')
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Moderator: Thread moved to the PowerCLI area.
thanks
You could do something like this
$nameArr = @('test')
$nameArr += $esx.Name.split('.')[2..3]
Get-VMHostNetwork -VMHost $esx |
Set-VMHostNetwork -HostName ($nameArr -join '-')
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
it works ,thanks for helping me!