We pre-imaged new computer with host name. However, due to DNS and DHCP issue, we always has 1,2 can’t ping remotely. If I can remote in subnet to ping, I can see it is alive. My next question is it any way to keep the hosts.txt on local drive instead of copying to remote computer.
Not sure I fully understand what you are doing, but to use local data i.e. your hosts file on a remote machine, you might want to assign the data to a variable and use the “using:” scope modifier in your invoke-command script block. See Get-Help About_Scopes for more info.