• This topic has 1 reply, 1 voice, and was last updated February 10, 2017 by Sung-Ki Y.

Post-Script for changing hostname.

  • Hello Guys.

     

    I create script for Changing hostname of failover VM.

     

    It works on manual running.

    But It doesn’t works on post-script section.

     

    Thank you

     

    I Don’t Know Why.

     

    Situation

     

    Post-Script with no params on VPG Setting

    C:\ZertoScripts\Change-RHEL-hostname.bat

     

    1. Change-RHEL-hostname.bat file

    powershell -file C:\ZertoScripts\Set-RHEL-Hostname.ps1 >> C:\ZertoScripts\Result-RHEL-Test.txt

     

    2. Set-RHEL-Hostname.ps1 file

    # source vSphere PowerCLI Environment first
    . “C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1”
    # custom code follows

    #Sleep 90 sec
    Start-sleep -sec 90

    #Connect to Vcenter Server
    Connect-VIServer -Server 1.1.1.1 -User administrator -Password Password -Port 443

    #Messages
    Write-Host “Setting Hostname for RHEL-Test-DR… ”

    #Change Hostname for RHEL

    #For Live Failover
    Invoke-VMScript -VM “RHEL-Test” -GuestUser root -GuestPassword Password -ScriptType BASH -ScriptText “hostname RHEL-Test-DR”

    #For Test Failvoer
    Invoke-VMScript -VM “RHEL-Test – testing recovery” -GuestUser root -GuestPassword Password -ScriptType BASH -ScriptText “hostname RHEL-Test-DR-T”

    #Messages
    Write-Host “Hostname is changed.”

    # Disconnect session vCenter
    Disconnect-VIserver -Confirm:$false

     

     

    This is all.

     

    Anyone have good Idea or example script, Please Let me know.

    Problem has resolved.

     

    I just Reboot the ZVM and all goes fine. 🙂

     

    Thank you, Guys

You must be logged in to create new topics. Click here to login