Issue with Invoke-VMScript

I’m trying to start a VM Automation script but I’m having issues with the network configuration piece.

$VM = Read-Host -Prompt "Enter VM name." $ipAddr = Read-Host -Prompt "Enter IP Address." $subMask = "" if (($Mask = Read-Host -Prompt "Enter subnet or hit enter for default []") -eq "" -or $null) {$mask = $subMask} else {$mask} $gw = Read-Host -Prompt "Enter the Gateway." $netsh = "C:WindowsSystem32netsh.exe interface ip set address name='Ethernet0' static $ipAddr $subMask $gw 1" Invoke-VMScript -VM $VM -ScriptType bat -ScriptText $netsh 

When I execute this code I get an error:

The filename, directory name, or volume label syntax is incorrect 

If I run the code locally, it works just fine.

submitted by /u/Throwaway061791
[link] [comments]

Leave a Reply