- Community Home
- >
- Software
- >
- HPE Morpheus Software
- >
- HPE Morpheus Enterprise Software
- >
- Re: Running PowerCLI Cmdlets in Morpheus Appliance
Categories
Company
Local Language
Forums
Discussions
- Integrity Servers
- Server Clustering
- HPE NonStop Compute
- HPE Apollo Systems
- High Performance Computing
Knowledge Base
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Knowledge Base
Forums
Discussions
- Cloud Mentoring and Education
- Software - General
- HPE OneView
- HPE Ezmeral Software platform
- HPE OpsRamp Software
Knowledge Base
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2024 04:14 AM
04-23-2024 04:14 AM
Running PowerCLI Cmdlets in Morpheus Appliance
Introduction:
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.
Prerequisites:
Before proceeding with running PowerCLI cmdlets on Morpheus appliance, ensure the following prerequisites are met:
- Install PowerShell Core (PWSH):
- Install PowerShell Core on all Morpheus appliance nodes.
- Open a terminal and type
pwshto access the PowerShell Core console.
- Install VMware PowerCLI Module:
- Install the VMware PowerCLI module using the following cmdlet:
Install-Module -Name VMware.PowerCLI.VCenter
Set-PowerCLIConfiguration -Scope AllUsers -ParticipateInCeip $false -confirm:$false
Set-PowerCLIConfiguration -Scope AllUsers -InvalidCertificateAction Ignore -confirm:$false
Creating a PowerShell Task:
- Navigate to Morpheus UI:
- Log in to the Morpheus UI with appropriate credentials.
- Create a Shell Task:
- Navigate to Tasks > Create Task.
- Select “Shell” as the task type and ensure “Execute as Sudo” is checked.
- Set the Execute target to “Local.”
- Sample PowerShell Script:
- In the task content, include the following PowerShell script block:
pwsh -command "& {
# PowerShell script block starts here
\$VM = '<%=instance.containers.server.name%>'
\$Instance = '<%=instance.name%>'
\$vCenterUser = '<%=cypher.read('secret/VcenterServiceAccount')%>'
\$vCenterPassword = '<%=cypher.read('secret/VcenterServiceAccountPassword')%>'
# 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
}"
Conclusion:
By following these steps, users can effectively leverage PowerCLI cmdlets within the Morpheus appliance environment to automate VMware vSphere tasks seamlessly.
- Tags:
- automation
- Tasks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2024 06:54 AM
04-23-2024 06:54 AM
Re: Running PowerCLI Cmdlets in Morpheus Appliance
@vsenthilkarasu appreciate the post!
You may want to check out this post here.
There are few things to note:
- PowerShell Task Type supports a local execution, so the shell script with interpretation is no longer needed.
- PowerShell Modules must be installed as
morpheus-local, or-scope allusers - Setting a JSON block in Cypher allows a singular reference to credentials for 1 or more vCenter at the same time