Powershell Script to rename VM from CSV based on Hostname of Hypervisor Server RRS feed

  • Question

  • Hello all,

    I would like to tap into your combined experiences to help me with renaming VM machine on a 2016 Hyper-V Core Host.

    Project Scope: Deploy 3-4K Intel NUCs nation-wide

    NUC configuration: Server 2016 Core with Hyper-V Role. Host has a single Guest OS of Server 2008 R2 in a Workgroup configured to run proprietary software by the client.

    Issue: Rename the Guest OS Hostname from a list of names that are associated to the Hostname of the Host Hyper-V Server.

    Proposed task: Query Host server for hostname. Take that Host Hostname and compare to CSV file on the Guest VM OS to read the associated Guest NewHostname as NewHostname. The script will then run Rename-Computer -computername -newname NewHostname -Restart to change the Guest VM Hostname. From what I read, -computername will default to the current local hostname of the VM.


    HOST-Hostname          Guest NewHostname

    SVR-HV16-0014             WES-2K8-0103

    SVR-HV16-0203             WES-2K8-3024

    SVR-HV16-1003             WES-2K8-0036

    Script will read Host Hostname of SVR-HV16-0203. It will then read CSV searching for SVR-HV16-0203 and then use the Guest Hostname of WES-2K8-3024 to rename the Guest VM Server and reboot. This will only run once.

    Any help in getting a script to perform this, is appreciated.



    Thursday, April 19, 2018 6:48 PM