<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Invoke-VMScript. Pass variable in BASH in VMware PowerCLI Discussions</title>
    <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Invoke-VMScript-Pass-variable-in-BASH/m-p/2814864#M98554</link>
    <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Fri, 04 Dec 2020 16:33:08 GMT</pubDate>
    <dc:creator>DanteMc</dc:creator>
    <dc:date>2020-12-04T16:33:08Z</dc:date>
    <item>
      <title>Invoke-VMScript. Pass variable in BASH</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Invoke-VMScript-Pass-variable-in-BASH/m-p/474401#M12830</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi LUCD, hi all!&lt;/P&gt;&lt;P&gt;Small script to change IP in CentoS&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_15541268854483607 jive_text_macro" data-renderedposition="112.44444274902344_8_1019_48" jivemacro_uid="_15541268854483607" modifiedtitle="true"&gt;&lt;P&gt;$IPguest = Read-Host -Prompt 'Enter IP Guest'&lt;/P&gt;&lt;P&gt;$script = "sed -i 's:^IPADDR=.*$:IPADDR=$IPguest:g' /etc/sysconfig/network-scripts/ifcfg-ens160"&lt;/P&gt;&lt;P&gt;Invoke-VMScript -VM CentOS-7 -ScriptType bash -ScriptText $script -GuestUser root -GuestPassword P@ssw0rd&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Error:sed: -e expression #1, char 13: unterminated `s' command&lt;/P&gt;&lt;P&gt;The problem here: $:IPADDR=$IPguest. &lt;/P&gt;&lt;P&gt;How can I pass variable in this case?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Apr 2019 14:01:08 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Invoke-VMScript-Pass-variable-in-BASH/m-p/474401#M12830</guid>
      <dc:creator>IKirill</dc:creator>
      <dc:date>2019-04-01T14:01:08Z</dc:date>
    </item>
    <item>
      <title>Re: Invoke-VMScript. Pass variable in BASH</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Invoke-VMScript-Pass-variable-in-BASH/m-p/474402#M12831</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are 2 issues:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;your end of line $ sign: you will have to escape it with a back-tick&lt;/LI&gt;&lt;LI&gt;you have the indicate the variable that needs to be substituted by enclosing it in parenthesis&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Try like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV&gt;&lt;SPAN style="color: #000000;"&gt;$&lt;/SPAN&gt;&lt;SPAN style="color: #ff4500;"&gt;IPguest&lt;/SPAN&gt; &lt;SPAN style="color: #a9a9a9;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff;"&gt;Read-Host&lt;/SPAN&gt; &lt;SPAN style="color: #a9a9a9;"&gt;-&lt;/SPAN&gt;Prompt &lt;SPAN style="color: #000000;"&gt;'&lt;/SPAN&gt;&lt;SPAN style="color: #8b0000;"&gt;Enter IP Guest&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;'&lt;/SPAN&gt; &lt;P&gt;&lt;SPAN style="color: #000000;"&gt;$&lt;/SPAN&gt;&lt;SPAN style="color: #ff4500;"&gt;script&lt;/SPAN&gt; &lt;SPAN style="color: #a9a9a9;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="color: #000000;"&gt;"&lt;/SPAN&gt;&lt;SPAN style="color: #8b0000;"&gt;sed -i 's:^IPADDR=.*`$:IPADDR=&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;$($&lt;/SPAN&gt;&lt;SPAN style="color: #ff4500;"&gt;IPguest&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;)&lt;/SPAN&gt;&lt;SPAN style="color: #8b0000;"&gt;:g' /etc/sysconfig/network-scripts/ifcfg-ens160&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;"&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;Invoke-VMScript&lt;/SPAN&gt; &lt;SPAN style="color: #a9a9a9;"&gt;-&lt;/SPAN&gt;VM CentOS&lt;SPAN style="color: #a9a9a9;"&gt;-&lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;7&lt;/SPAN&gt; &lt;SPAN style="color: #a9a9a9;"&gt;-&lt;/SPAN&gt;ScriptType bash &lt;SPAN style="color: #a9a9a9;"&gt;-&lt;/SPAN&gt;ScriptText &lt;SPAN style="color: #000000;"&gt;$&lt;/SPAN&gt;&lt;SPAN style="color: #ff4500;"&gt;script&lt;/SPAN&gt; &lt;SPAN style="color: #a9a9a9;"&gt;-&lt;/SPAN&gt;GuestUser root &lt;SPAN style="color: #a9a9a9;"&gt;-&lt;/SPAN&gt;GuestPassword P&lt;SPAN style="color: #000000;"&gt;@&lt;/SPAN&gt;&lt;SPAN style="color: #ff4500;"&gt;ssw0rd&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Apr 2019 14:39:35 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Invoke-VMScript-Pass-variable-in-BASH/m-p/474402#M12831</guid>
      <dc:creator>LucD</dc:creator>
      <dc:date>2019-04-01T14:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: Invoke-VMScript. Pass variable in BASH</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Invoke-VMScript-Pass-variable-in-BASH/m-p/474403#M12832</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks LucD!&lt;/P&gt;&lt;P&gt;You are absolutely amazing master!!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Apr 2019 20:17:25 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Invoke-VMScript-Pass-variable-in-BASH/m-p/474403#M12832</guid>
      <dc:creator>IKirill</dc:creator>
      <dc:date>2019-04-01T20:17:25Z</dc:date>
    </item>
    <item>
      <title>Re: Invoke-VMScript. Pass variable in BASH</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Invoke-VMScript-Pass-variable-in-BASH/m-p/2814682#M98539</link>
      <description>&lt;P&gt;I may be having a similar problem. I am getting the following error:&lt;/P&gt;&lt;P&gt;PS&amp;gt; Invoke-VMScript -VM CentOS7 -ScriptText 'sed -ri "s|10.28.183.204|10.28.164.138|" /etc/sysconfig/network-scripts/ifcfg-ens192' -GuestUser root -GuestPassword password&lt;/P&gt;&lt;P&gt;Invoke-VMScript : 12/3/2020 5:12:26 PM Invoke-VMScript An error occurred while sending the request.&lt;BR /&gt;At line:1 char:1&lt;BR /&gt;+ Invoke-VMScript -VM CentOS7 -ScriptText 'sed -ri "s|10.28.183. ...&lt;BR /&gt;+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;BR /&gt;+ CategoryInfo : NotSpecified: (:) [Invoke-VMScript], ViError&lt;BR /&gt;+ FullyQualifiedErrorId : Client20_VmGuestServiceImpl_DownloadFileFromGuest_DownloadError,VMware.VimAutomation.ViCore.Cmdlets.Commands.InvokeVmScript&lt;/P&gt;&lt;P&gt;After hitting enter on the PS command, it takes 3 minutes 52 seconds (I used a stopwatch) before PS returns the error message but the SED change is made on the host within a few seconds.&amp;nbsp; Why is the console hanging up for 3m52s before returning the error but the command executed within seconds on the host?&lt;/P&gt;&lt;P&gt;GuestOS:&amp;nbsp; CentOS7_1908 w/ VMWare Tools v11.0.5.17716 running&lt;/P&gt;&lt;P&gt;PowerShell v5.1.14393.2969 with PowerCLI v12.1.0 on Win Svr 2016&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 00:56:30 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Invoke-VMScript-Pass-variable-in-BASH/m-p/2814682#M98539</guid>
      <dc:creator>DanteMc</dc:creator>
      <dc:date>2020-12-04T00:56:30Z</dc:date>
    </item>
    <item>
      <title>Re: Invoke-VMScript. Pass variable in BASH</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Invoke-VMScript-Pass-variable-in-BASH/m-p/2814723#M98545</link>
      <description>&lt;P&gt;I don't think you are experiencing a similar problem.&lt;BR /&gt;Your code inside the Guest OS is working, it seems to be the transfer back from the result of the run to the calling station that seems to be experiencing an issue.&lt;BR /&gt;This might be a certificate issue on the ESXi node where the VM is running (missing SAN = Subject Alternative Name, more specifically the IP address).&lt;BR /&gt;&lt;BR /&gt;I would suggest opening a new thread.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 08:01:17 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Invoke-VMScript-Pass-variable-in-BASH/m-p/2814723#M98545</guid>
      <dc:creator>LucD</dc:creator>
      <dc:date>2020-12-04T08:01:17Z</dc:date>
    </item>
    <item>
      <title>Re: Invoke-VMScript. Pass variable in BASH</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Invoke-VMScript-Pass-variable-in-BASH/m-p/2814864#M98554</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 16:33:08 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Invoke-VMScript-Pass-variable-in-BASH/m-p/2814864#M98554</guid>
      <dc:creator>DanteMc</dc:creator>
      <dc:date>2020-12-04T16:33:08Z</dc:date>
    </item>
  </channel>
</rss>

