VMware Cloud Community
IKirill
Enthusiast
Enthusiast
Jump to solution

Copy variable from one host to another

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"

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

View solution in original post

Reply
0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
IKirill
Enthusiast
Enthusiast
Jump to solution

Thanks! working!

Reply
0 Kudos