Hi!
I wont to copy dns and ntp information from one host to another.
Script don't work. Pls help)
$esxiServer1 = Read-Host -Prompt 'enter esx1'
$esxiServer2 = Read-Host -Prompt 'enter esx2'
$dnsesxi=Get-VMHost -Name $esxiServer2 | Get-VMHostNetwork | Select DNSAddress
Get-VMHost -Name $esxiServer1 | Get-VMHostNetwork | Set-VMHostNetwork -DnsAddress "$dnsesxi"
Try like this
$esxiServer1 = Read-Host -Prompt 'enter esx1'
$esxiServer2 = Read-Host -Prompt 'enter esx2'
$dnsAddr = Get-VMHost $esxiServer1 | Get-VMHostNetwork | select -ExpandProperty DnsAddress
Get-VMHost $esxiServer2 | Get-VMHostNetwork | Set-VMHostNetwork -DnsAddress $dnsAddr
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try like this
$esxiServer1 = Read-Host -Prompt 'enter esx1'
$esxiServer2 = Read-Host -Prompt 'enter esx2'
$dnsAddr = Get-VMHost $esxiServer1 | Get-VMHostNetwork | select -ExpandProperty DnsAddress
Get-VMHost $esxiServer2 | Get-VMHostNetwork | Set-VMHostNetwork -DnsAddress $dnsAddr
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks! working!