Reply to Message

View discussion in a popup

Replying to:
IKirill
Enthusiast
Enthusiast

Invoke-VMScript. Pass variable in BASH

Hi LUCD, hi all!

Small script to change IP in CentoS

$IPguest = Read-Host -Prompt 'Enter IP Guest'

$script = "sed -i 's:^IPADDR=.*$:IPADDR=$IPguest:g' /etc/sysconfig/network-scripts/ifcfg-ens160"

Invoke-VMScript -VM CentOS-7 -ScriptType bash -ScriptText $script -GuestUser root -GuestPassword P@ssw0rd

Error:sed: -e expression #1, char 13: unterminated `s' command

The problem here: $:IPADDR=$IPguest.

How can I pass variable in this case?

Reply
0 Kudos