Hi,
I have list datastores Name, I need to get the respective hosts cluster name in powercli. Please help me.
Thanks
You didn't specify in which format that "list datastores Name" is provided, but when I assume it is a CSV with a column named DSName, you could do
Getting error as attached.
Where is that Disconnect-VIServer coming from?That was not in the code I posted.The code assumes you are connected to the vCenter.
Disconnect-VIServer is added my self. Script is working now. But, When I try to export data in CSV, getting cluster detail for only one datastore only. otherwise on screen output shows for all datastore.
That probably means you placed the Export-Csv inside the Forwach-Object loop, hence overwriting the CSV each time.You have to place the Export-Csv outside the Foreach-Object code block
Now, I have kept my Export-CSV in out of foreach, but still I am getting cluster detail only for last datastore in the list.
Can you show the code you are using?
Unable to copy and paste the code here due to limited access, just providing the screenshot of the code.
You are overwriting the variable $p inside the loop each time.
How can I stop overwriting $p in the script.
Perhaps you could use the code I give and not change it?
I tried with your code and getting below error.
I found the issue and fixed it..
It works now..
Thank you LucD