Solved

Gathering info from several clusters with Powershell

  • 2 March 2018
  • 7 replies
  • 4142 views

Badge
What is the best method for collecting info on multiple clusters at once? We have Prism Central and about 20 clusters, so I thought I could connect to PC and get everything from it but this has been a bit challenging.

For instance: Trying to get SMTP settings from all clusters-

code:
Connect-NutanixCluster -server my.prismcentral.foobar
$myClusters = Get-NTNXCluster
$myClusters | foreach { Get-NTNXSmtpServer -NutanixClusters $_ }


This results in:
code:
Get-NTNXSmtpServer : Cannot bind parameter 'NutanixClusters'. Cannot convert the "Nutanix.Prism.DTO.Appliance.Configuration.ClusterDTO" value of type
"Nutanix.Prism.DTO.Appliance.Configuration.ClusterDTO" to type "Nutanix.Prism.Common.NutanixCluster".



If I run Get-NTNXSmtpServer with no parameters, it returns Prism Central's config. What's the correct way to do something like this example?
icon

Best answer by aluciani 13 March 2018, 20:05

Hi @glarkins-71916

Have you seen this site - http://developer.nutanix.com/ got some good content that might help. Let me know what you think. Thanks
View original

7 replies

Userlevel 4
Badge +19
@glarkins-71916

Currently CMDLET is created on REST v1 and this issue will be fixed with new version of CMDLET on v3.


For now , you would need to gather this info directly from clusters.
Userlevel 7
Badge +35
Hi @glarkins-71916

Did the reply from @sandeepmp help? If yes, consider clicking the 'Best Answer' link - that will help others on the community find answer to the same question more quickly. Thanks
Badge
When are the v3 cmdlets anticipated to be released? Is there a beta I could participate in?
Userlevel 7
Badge +35
Hi @glarkins-71916

Have you seen this site - http://developer.nutanix.com/ got some good content that might help. Let me know what you think. Thanks
Badge
I have looked over some of the examples posted there, which may be of some use. I was going to craft powershell scripts to use the API is I had to, but this is something new to me with powershell and I'd rather not re-invent the wheel if a ready made cmdlet can do these things.
Userlevel 1
Badge +1

Hi glarkins-71916, 

Looking over the code you provided you are setting the variable incorrectly:

Connect-NutanixCluster -server my.prismcentral.foobar
$myClusters = Get-NTNXCluster

##this below line is incorrect, if I am reading correctly
$myClusters | foreach { Get-NTNXSmtpServer -NutanixClusters $_ }

##you would want to set your variable, then foreach item in the variable

$myClusters = Get-NTNXCluster
foreach($myClusters){
 
    get-ntnxsmtpserver
    
    
}

Userlevel 1
Badge +1

Hi glarkins-71916, 

 

I did some testing and there appears to also be an issue with running the cmdlets on a prism central endpoint. That being the case you could import a csv with the clusters, then connect to the multiple clusters to run the get-ntnxsmtp command. 

 

connect-ntnxcluster cluster1,cluster2,cluster3

 

or import csv, foreach cluster in the csv connect. Either way as long we are using powershell to connect to the “clusters” not prism central. 

Reply