VMware Cloud Community
adolphelc
Contributor
Contributor

Report [vCenter] [Host] [naa (canonicalname)] [DatastoreName] [NumberOfPaths] [VENDOR] [LUN ID]

Hello,Smiley Happy

I am beginner on powershell / Powercli trying to make a report with the fields mentioned in the title.

([vCenter] [Host] [naa (canonicalname)] [DatastoreName] [NumberOfPaths] [VENDOR] [LUN ID])

The reviewed within this great community the following discussions

https://code.vmware.com/forums/2530/?page=2#586132

https://code.vmware.com/forums/2530/vsphere-powercli#581463

https://communities.vmware.com/message/2635694#2635694

I have not managed to look at more examples to make a report with the desired fields.

I found this code on this website.

http://www.vmwarealert.com/2018/06/powercli-script-to-get-datastore.html

worked well!!!  but I would like to omit some fields that I do not need...

I have tried to comment on the lines of the unwanted fields but it stopped working and I think the "}" is not well defined but I'm not sure.
on the web you can see the original code is barely modified since I was testing and learning with it (attach).

If someone can help me or redirect me to a code that reports this information, I would greatly appreciate it

I would also like to convert it into html and the body of an email, but this is another issue

regards!!!

20 Replies
LucD
Leadership
Leadership

What exactly is not working for you?
Seems to work for me.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

adolphelc
Contributor
Contributor

Hi lucD !!

It is an honor to receive your reply.

The problem is that the original ".csv" does not come out correctly.

I just want to exclude what is commented but it seems that the output is not well defined see attachments, green - original output script
red- my script output

Reply
0 Kudos
LucD
Leadership
Leadership

Ok, I see what you mean.
The closing curly brace for the function is missing.

The lines

    $Obj                                                             

   }

should

    $Obj

   }

}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
adolphelc
Contributor
Contributor

lucD,

Thanks again, if I mainly thought it was this but if I put it where you indicate it gives me an error (see attachments)

so I don't know if when # commenting the code .. I need to put more {} ..

thank you very much

Reply
0 Kudos
LucD
Leadership
Leadership

You seem to have an uncommented brace in the beginning.
Try the attached script


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
adolphelc
Contributor
Contributor

Hi lucD,

Thank you very much again I run it but it does nothing.

Taking away the complexity of the problem, I would use the fields

1-vCenter
2-host
3-naa (canonicalname) 4-NumberOfPaths 5-DatastoreName
6-Capacity
7-FreeSpace

PS_Report_Info_3.png

I have commented the code again removing fields but it indicates errors if I leave} where we have been testing but it still does nothing ..

PS_Report_Info_4.png

Attach new version... not run Smiley Sad

Reply
0 Kudos
LucD
Leadership
Leadership

That is correct, the script creates a CSV file.
Is that there?

Which it then sends as an email attachment.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
adolphelc
Contributor
Contributor

Yes but it does not dump the information ..

PS_Report_Info_5.png

I have tried two runs and the result is the same.

Reply
0 Kudos
LucD
Leadership
Leadership

That is not the script I attached


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
adolphelc
Contributor
Contributor

ups... attach

Reply
0 Kudos
LucD
Leadership
Leadership

The closing curly brace for the function was again incorrect.

Try the attached version


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

adolphelc
Contributor
Contributor

LucD, thank you once again, unfortunately the same thing happens, I have cleaned the code and I do not find errors except those shown by VS code.

PS_Report_Info_6.png

I understand that this is not the error

attached "new version"

Reply
0 Kudos
LucD
Leadership
Leadership

That version works for me


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
adolphelc
Contributor
Contributor

LucD,

I'm going to test it tomorrow in another vmware environment since my home lab sometimes does strange things, thanks for your help tomorrow I comment ...

regards

Reply
0 Kudos
adolphelc
Contributor
Contributor

Hi LucD,

you were right if that works. but the csv has lost information.

BadReport.png

Reviewing I saw that delete the variable $ Datastorename

so I tried adding it with "$ Datastore Name = Get-Datastore | Sort-Object" but I think it comes in with "$ DatastoreInfo = Get-Datastore"

and I have tried to add vCenter and make it multi vcenter to run it in more than 20 vcenters simultaneously

but I have ended it by breaking completely ha ha ha ... I think it's because of the foreach

attched new version

Reply
0 Kudos
LucD
Leadership
Leadership

Try with this version


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

adolphelc
Contributor
Contributor

LucD,

Thanks I understand!!!  the function is defined and after the execution of the script ... now VMHost is lost

BadReport.png

I have tried to fix it but ...

BadReport.png

attch new version

thanks again regards

Reply
0 Kudos
LucD
Leadership
Leadership

I'm not sure why the VMHost is missing for you, for me it works.
Can't really change anything if it works


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
adolphelc
Contributor
Contributor

LucD,

Ok thanks Smiley Wink I am going to test it in a physical environment in the end it seems that my lab is not so reliable ..

I comment on results!

thanks for your timeSmiley Happy Master!!

Reply
0 Kudos