<?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: Running PowerCLI Cmdlets in Morpheus Appliance in HPE Morpheus Enterprise Software</title>
    <link>https://community.hpe.com/t5/hpe-morpheus-enterprise-software/running-powercli-cmdlets-in-morpheus-appliance/m-p/7251142#M4316</link>
    <description>&lt;P&gt;&lt;A class="mention" href="https://community.hpe.com/u/vsenthilkarasu"&gt;@vsenthilkarasu&lt;/A&gt; appreciate the post!&lt;/P&gt;
&lt;P&gt;You may want to check out this post &lt;A href="https://discuss.morpheusdata.com/t/vmware-anti-affinity-rules/318"&gt;here&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;There are few things to note:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;PowerShell Task Type supports a local execution, so the shell script with interpretation is no longer needed.&lt;/LI&gt;
&lt;LI&gt;PowerShell Modules must be installed as &lt;CODE style="background : #f0f1f2;"&gt;morpheus-local&lt;/CODE&gt;, or &lt;CODE style="background : #f0f1f2;"&gt;-scope allusers&lt;/CODE&gt;&lt;/LI&gt;
&lt;LI&gt;Setting a JSON block in Cypher allows a singular reference to credentials for 1 or more vCenter at the same time&lt;/LI&gt;
&lt;/UL&gt;</description>
    <pubDate>Tue, 23 Apr 2024 13:54:27 GMT</pubDate>
    <dc:creator>cbunge</dc:creator>
    <dc:date>2024-04-23T13:54:27Z</dc:date>
    <item>
      <title>Running PowerCLI Cmdlets in Morpheus Appliance</title>
      <link>https://community.hpe.com/t5/hpe-morpheus-enterprise-software/running-powercli-cmdlets-in-morpheus-appliance/m-p/7251141#M4315</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Introduction:&lt;/STRONG&gt;&lt;BR /&gt;
In this article, we will outline the steps to run PowerCLI cmdlets within a Morpheus appliance environment. This capability allows users to automate VMware vSphere tasks directly from the Morpheus platform.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Prerequisites:&lt;/STRONG&gt;&lt;BR /&gt;
Before proceeding with running PowerCLI cmdlets on Morpheus appliance, ensure the following prerequisites are met:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;STRONG&gt;Install PowerShell Core (PWSH):&lt;/STRONG&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;UL&gt;
&lt;LI&gt;Install PowerShell Core on all Morpheus appliance nodes.&lt;/LI&gt;
&lt;LI&gt;Open a terminal and type &lt;CODE style="background : #f0f1f2;"&gt;pwsh&lt;/CODE&gt; to access the PowerShell Core console.&lt;/LI&gt;
&lt;/UL&gt;
&lt;OL start="2"&gt;
&lt;LI&gt;&lt;STRONG&gt;Install VMware PowerCLI Module:&lt;/STRONG&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;UL&gt;
&lt;LI&gt;Install the VMware PowerCLI module using the following cmdlet:&lt;/LI&gt;
&lt;/UL&gt;
&lt;PRE style="background : #f0f1f2;"&gt;&lt;CODE class="lang-auto"&gt;Install-Module -Name VMware.PowerCLI.VCenter
Set-PowerCLIConfiguration -Scope AllUsers -ParticipateInCeip $false -confirm:$false
Set-PowerCLIConfiguration -Scope AllUsers -InvalidCertificateAction Ignore -confirm:$false
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;Creating a PowerShell Task:&lt;/STRONG&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;STRONG&gt;Navigate to Morpheus UI:&lt;/STRONG&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;UL&gt;
&lt;LI&gt;Log in to the Morpheus UI with appropriate credentials.&lt;/LI&gt;
&lt;/UL&gt;
&lt;OL start="2"&gt;
&lt;LI&gt;&lt;STRONG&gt;Create a Shell Task:&lt;/STRONG&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;UL&gt;
&lt;LI&gt;Navigate to Tasks &amp;gt; Create Task.&lt;/LI&gt;
&lt;LI&gt;Select “Shell” as the task type and ensure “Execute as Sudo” is checked.&lt;/LI&gt;
&lt;LI&gt;Set the Execute target to “Local.”&lt;/LI&gt;
&lt;/UL&gt;
&lt;OL start="3"&gt;
&lt;LI&gt;&lt;STRONG&gt;Sample PowerShell Script:&lt;/STRONG&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;UL&gt;
&lt;LI&gt;In the task content, include the following PowerShell script block:&lt;/LI&gt;
&lt;/UL&gt;
&lt;PRE style="background : #f0f1f2;"&gt;&lt;CODE class="lang-auto"&gt;pwsh -command "&amp;amp; {
    # PowerShell script block starts here
    \$VM = '&amp;lt;%=instance.containers.server.name%&amp;gt;'
    \$Instance = '&amp;lt;%=instance.name%&amp;gt;'
    \$vCenterUser = '&amp;lt;%=cypher.read('secret/VcenterServiceAccount')%&amp;gt;'
    \$vCenterPassword = '&amp;lt;%=cypher.read('secret/VcenterServiceAccountPassword')%&amp;gt;'

    # Convert plaintext password to a secure string
    \$secStringPassword = ConvertTo-SecureString \$vCenterPassword -AsPlainText -Force

    # Create PSCredential object with the provided credentials
    \$vCreds = New-Object System.Management.Automation.PSCredential (\$vCenterUser, \$secStringPassword)

    # Define vCenter server IP address or hostname
    \$vCenters = 'XXXXXXXXXXXXXXXXXXXXXXXX'

    # Connect to the vCenter server using the provided credentials
    Connect-VIServer \$vCenters -Credential \$vCreds
}"
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;Conclusion:&lt;/STRONG&gt;&lt;BR /&gt;
By following these steps, users can effectively leverage PowerCLI cmdlets within the Morpheus appliance environment to automate VMware vSphere tasks seamlessly.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2024 11:14:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/hpe-morpheus-enterprise-software/running-powercli-cmdlets-in-morpheus-appliance/m-p/7251141#M4315</guid>
      <dc:creator />
      <dc:date>2024-04-23T11:14:57Z</dc:date>
    </item>
    <item>
      <title>Re: Running PowerCLI Cmdlets in Morpheus Appliance</title>
      <link>https://community.hpe.com/t5/hpe-morpheus-enterprise-software/running-powercli-cmdlets-in-morpheus-appliance/m-p/7251142#M4316</link>
      <description>&lt;P&gt;&lt;A class="mention" href="https://community.hpe.com/u/vsenthilkarasu"&gt;@vsenthilkarasu&lt;/A&gt; appreciate the post!&lt;/P&gt;
&lt;P&gt;You may want to check out this post &lt;A href="https://discuss.morpheusdata.com/t/vmware-anti-affinity-rules/318"&gt;here&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;There are few things to note:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;PowerShell Task Type supports a local execution, so the shell script with interpretation is no longer needed.&lt;/LI&gt;
&lt;LI&gt;PowerShell Modules must be installed as &lt;CODE style="background : #f0f1f2;"&gt;morpheus-local&lt;/CODE&gt;, or &lt;CODE style="background : #f0f1f2;"&gt;-scope allusers&lt;/CODE&gt;&lt;/LI&gt;
&lt;LI&gt;Setting a JSON block in Cypher allows a singular reference to credentials for 1 or more vCenter at the same time&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Tue, 23 Apr 2024 13:54:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/hpe-morpheus-enterprise-software/running-powercli-cmdlets-in-morpheus-appliance/m-p/7251142#M4316</guid>
      <dc:creator>cbunge</dc:creator>
      <dc:date>2024-04-23T13:54:27Z</dc:date>
    </item>
  </channel>
</rss>

