Hi Folks
I want to append few lines in ESX /etc/vmware/hostd/config.xml file within a particular tag.
here is m requirement.
- Search for <useCompression>true</useCompression> in /etc/vmware/hostd/config.xml
- Update below line underneath it
<handshakeTimeoutMs>120000</handshakeTimeoutMs>
- To achieve this I am using awk command and passing it over powershell
- awk command works fine if I run it manually on host itself.
cd /var/tmp;cp config.xml config.xml.backup ;cat config.xml | awk '{ if ($1 == "<useCompression>true</useCompression>") { print $0; print " <handshakeTimeoutMs>120000</handshakeTimeoutMs>"} else {print $0}}'>config.xml_new ;mv -f config.xml_new config.xml
- Below is my powershell script which fails with syntax error
========================
$PuttyFold ="E:\folder"
$plink = "echo Y |$PuttyFold\plink.exe"
$user = "root"
$pd = "XXXXX"
$plinkoptions = " -v -pw $pd"
$esx ="abc"
$d = "<handshakeTimeoutMs>120000</handshakeTimeoutMs>"
$e = '"' + $d + '"'
$j = "<useCompression>true</useCompression>"
$k = '"' + $j + '"'
$cmd = "cd /etc/vmware/hostd;cp config.xml config.xml.backup ;cat config.xml | awk '{if($1 == $j){ print $0; print $d} else {print $0}}' > config.xml_new ; mv -f config.xml_new config.xml"
$remotecommand = '"' +$cmd + '"'
$command = $plink + " " + $plinkoptions + " " + $user + "@" + $esx + " " + $remotecommand
Invoke-Expression -Command $command -ErrorAction SilentlyContinue
========================
- When I execute my script, I get error in attached screenshot
Please advice
Thanks
Heera