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 "##########################################################################"
That normally indicates that the interface name on the netsh command is not correct.
Find the correct name with
netsh interface show interface
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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
##########################################################################
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)
$result = Invoke-VMScript -VM $VmName -ScriptText $cmdDNS1 -GuestUser administrator -GuestPassword xxxxxx
Or you can redirect it to NULL
Invoke-VMScript -VM $VmName -ScriptText $cmdDNS1 -GuestUser administrator -GuestPassword xxxxxx | Out-Null
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thak you Very much ![]()
