解决了

Failing to execute Set-NTNXVMPowerState from PoSH Script - access denied

  • 7 March 2019
  • 1回复
  • 1862 views

徽章 +1
I've written a PoSH script which does the following.
  1. Authenticates to Prism Central V3 API
  2. Calls /category/query API to get a list of VM uuid's that are members of the PROD category.
  3. Write this list of uuid's to a string
  4. Connect to the NTNX cluster using Nutanix PowerShell cmdlets.
  5. Iterate through the above string and execute Set-NTNXVMPowerState against the uuid's.
Steps 1 - 4 work as expected. Step 5 seems to iterate through the list as it should but when I put in the Set-NTNXVMPowerState command to be executed, it throws an access denied error.

Once the script gives the error, the powershell connection looks like it locks the account and you cannot execute any commands.

If I comment out the foreach loop, and just execute a normal PoSH cmdlet (after the Connect-NTNXCluster) such as Get-NTNXClusterInfo, it works fine.

I have tried both my account (which has Prism admin rights) and the Prism Central admin account with no luck.

So 2 questions:
  1. Any ideas what the problem is with the code?
  2. Would there be any issues with the starter license in executing Set-NTNX* commands?
See the link below for the script code:
https://github.com/leepryor/Nutanix_Powershell/blob/master/Shutdown-Categorized-VMs.ps1
图标

最好的答案devwangler12 March 2019, 01:54

\r\n
\r\nYou have to invoke the api via Prism.
\r\n
\r\nWhen you run the PS cmdlets, these need to be run against the cluster itself. If you're using my code above, i've already made the changes required for this.","className":"post__content__best_answer"}">
查看原件

1回复

徽章 +1
I worked out the problem.

You have to invoke the api via Prism.

When you run the PS cmdlets, these need to be run against the cluster itself. If you're using my code above, i've already made the changes required for this.

回复


Learn more about our cookies.<\/a>","cookiepolicy.button":"Accept cookies","cookiepolicy.button.deny":"Deny all","cookiepolicy.link":"Cookie settings","cookiepolicy.modal.title":"Cookie settings","cookiepolicy.modal.content":"We use 3 different kinds of cookies. You can choose which cookies you want to accept. We need basic cookies to make this site work, therefore these are the minimum you can select. Learn more about our cookies.<\/a>","cookiepolicy.modal.level1":"Basic
Functional","cookiepolicy.modal.level2":"Normal
Functional + analytics","cookiepolicy.modal.level3":"Complete
Functional + analytics + social media + embedded videos"}}}">
Baidu