- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There are 2 issues:
- your end of line $ sign: you will have to escape it with a back-tick
- you have the indicate the variable that needs to be substituted by enclosing it in parenthesis
Try like this
$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
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference