Automation

 View Only
  • 1.  warning in output of invoke-vmscript

    Posted Nov 10, 2023 07:06 PM

     

    Hello 

    I got this warning output of invoke-vmscript. what this mean and to correct

    VERBOSE: Performing the operation "Invoke-VMScript" on target "win2019-2".
    VERBOSE: 11/10/2023 5:16:30 PM Invoke-VMScript Finished execution

    VM : win2019-2
    ExitCode : 0
    ScriptOutput : The filename, directory name, or volume label syntax is incorrect.

     

    The script

     

    $cmdIP = "netsh interface ipv4 set address name=`"$Ethernet`" static $newIP 255.255.255.0 $newGateWay"
    $cmdDNS1 = "netsh interface ipv4 set dns name=`"$Ethernet`" static $DNS"


    #$vm = Get-VM $hostname

    Invoke-VMScript -VM $VmName -ScriptText $cmdIP -GuestUser administrator -GuestPassword xxxxxx -Verbose

    write-host "##########################################################################"
    write-host "Setting network for $Ethernet in $VmName machine #########################"
    write-host "##########################################################################"

    Invoke-VMScript -VM $VmName -ScriptText $cmdDNS1 -GuestUser administrator -GuestPassword xxxxxx -Verbose

    write-host "##########################################################################"
    write-host "Setting DNS network for $Ethernet in $VmName machine #####################"
    write-host "##########################################################################"



  • 2.  RE: warning in output of invoke-vmscript

    Posted Nov 10, 2023 07:41 PM

    That normally indicates that the interface name on the netsh command is not correct.
    Find the correct name with



  • 3.  RE: warning in output of invoke-vmscript

    Posted Nov 10, 2023 08:37 PM

    Tank you LucD

    You'r right, Have an error to pit to the good Ethernet

    issue resolve 
    just one more question : is there any way to ignore the output of invoke-vmscript . I mean this output

    ##########################################################################
    VERBOSE: Performing the operation "Invoke-VMScript" on target "win2019".
    VERBOSE: 11/10/2023 9:31:45 PM Invoke-VMScript Finished execution

    VM : win2019
    ExitCode : 0
    ScriptOutput :

    Uid : /VIServer=vsphere.local\administrator@10.95.53.10:443/VirtualMachine=VirtualMachine-vm-130/VMScriptResult=-841959517_0/
    Length : 2

    ##########################################################################



  • 4.  RE: warning in output of invoke-vmscript

    Posted Nov 10, 2023 08:43 PM

    You are having 2 types of output streams.
    The Verbose stream which can simply avoid by removing the Verbose switch from the Invoke-VMScript cmdlet.

    The standard output of the cmdlet can be stored in a variable (if you need the results later on)

    Or you can redirect it to NULL

      



  • 5.  RE: warning in output of invoke-vmscript

    Posted Nov 10, 2023 08:57 PM

    Thak you Very much