Hey there ,
Introduction
i don't have many Experience with Powershell but want to learn it cause it is a great tool to get many Informations about VMs with the PowerCLI.
ToDo:
I want to create a PowerCLI-Code which gives me pretty much all the Information about a virtual machine Hardware
vCPUs
vRAM
NIC with MAC-Address and NIC-type
Disks with their DatastorePath and SCSI IDs
SCSI Controller with their IDs
Whats going on in my mind
I Have my VM "OL-LAB-DC-01"
where i can see from the vSphere Client the following Information:
1 vCPU,
2GB RAM
80GB ThinProvisioned Disk with the Datadsore Path on SCSI-Controller 0 and SCSI ID 0:0
SCSI-Controller 0 = LSI Logic SAS
NIC 3 is a VMXNET 3 NIC with Portgroup VM Network and the MAC-Adress XYZ
Thats the easy way but nobody would like to get this for each virtual Machine and thats why i need PowerCLI
First Steps
So far i can get mostly everything with one specific command:
vCPUs: Get-VM OL-LAB-DC-01
vRAM: Get-VM OL-LAB-DC-01
NICs: Get-VM OL-LAB-DC-01 | Get-NetworkAdapter
Get-VM OL-LAB-DC-01 | Get-Harddisk
Get-VM OL-LAB-DC-01 | Get-ScsiController
Questions
Apart from CPU, Memory and the NICs there is Information which i'm missing
How can i know that the vmdk is ThinProvisioned? I only get the output: Capacyity Persistence Filename?
How can i get the used SCSI IDs for the vmdks? And see on which SCSI ID (0) the SCSI-Controller is?
I Know that i can actually somehow use -ExpandProperty and select Propertys which aren't shown with the normal command (I used that from a code-snipplet to get VMs with their Appropriate Tag)- where do i find all those selectable Propertys?
The Second Question which i have is: found it @{N='NAME';E={(Get-whatiwant $_).Object}}
How can i get a one-liner out of that so that in the End it prints me out a Table where i have everything next to each other? Just Piping it trough will end in giving me errors because the pipe will refer to the command used before piping...
Thx for reading!
It's not like i wanna be a freeloader and get the Code-Snipplet because i'm lazy Rather than that I would like to try it myself but i need answers for my Questions
Best regards!
:Edit:
So far i have this massive one-liner which will get definitely longer...:
Get-VM ol-lab-dc-01 | Select-Object Name,NumCPU,MemoryGB,@{N='NIC-Name';E={(Get-NetworkAdapter $_).Name}},@{N='Portgruppe';E={(Get-NetworkAdapter $_).NetworkName}},@{N='Type';E={(Get-NetworkAdapter $_).Type}},@{N='MAC-Adresse';E={(Get-NetworkAdapter $_).MacAddress}},@{N='vmdk';E={(Get-HardDisk $_).DiskType}}