PowerShell script for use with Nutanix Era. Provisions Linux-based database engines, to call X-Play playbook that set VM categories in Prism Central.
To use update the below fields with your environments info.
- Username and password that as access to Prism Central.
- $user =
youruser
- $password =
yourpassword
- $user =
- Valid ip address or FQDN for Prism Central
- $pcaddress =
yourpcaddress
- $pcaddress =
- Webhook ID copied from X-Play playbook that sets catagory
- webhookid =
yourwebhookid
- webhookid =
#Change user and password to valid user
$user = "youruser"
$password = "yourpassword"
#Change pcadderss to ipaddress to fqdn of your prism central
$pcaddress = "yourpcaddress"
#Put your webhook_id from playbook
$webhookid = "yourwebhookid"
#Do not change anything after this comment
$auth = "$user" + ':' + "$password"
$Encoded = [System.Text.Encoding]::UTF8.GetBytes($auth)
$authorizationInfo = [System.Convert]::ToBase64String($Encoded)
$hostname = "$ENV:COMPUTERNAME"
$service = "https://$pcaddress`:9440/api/nutanix/v3/action_rules/trigger"
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", "Basic $($authorizationInfo)")
$headers.Add("Content-Type", "application/json")
$body = "{`n `"trigger_type`": `"incoming_webhook_trigger`",`n `"trigger_instance_list`":
[{`n `"webhook_id`": `"$webhookid`",`n `"string1`": `"$hostname`"`n }]`n}"
$response = Invoke-RestMethod -Uri $service -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json
# These code samples are intended as a standalone examples. Subject to licensing restrictions defined on Nutanix.dev,
# these can be downloaded, copied and/or modified in any way you see fit.
# Please be aware that all public code samples provided by Nutanix are unofficial in nature,
# are provided as examples only, are unsupported and
# will need to be heavily scrutinized and potentially modified before they can be used in a production environment.
# All such code samples are provided on an as-is basis,
# and Nutanix expressly disclaims all warranties, express or implied.
# All code samples are © Nutanix, Inc., and are provided as-is under the MIT license (https://opensource.org/licenses/MIT).