I am making a script to run in powershell (powerCLI) for vmware. I try to do a automatic report exported to a csv file but i dont know how to resolve couple of problems.
All parameters which i dont know how to export them.
"virtual machine working location" I can export disks where is a mashine, but i don't know how to export all path with folders.
domain / workgroup
Name of computer When i try to export a name i get name with domain "name.domainname.com" (that is strange because my VM are not in domain, there are in workgroup) name i mean a name inside of OS not in esxi, because esxi name of vm i get from this
$name = (get-vm name_maschine|select-object name).name
or simple when in loop parameter is a name of mashine, i only export a parameter
less important parameters
4 . The name of vcenter in which host is working
- The name of datacenter in which host is working
Code:
connect-viserver -server IP-ADDRES -user root -password PASSWORD
Get-View -ViewType VirtualMachine | %{
New-Object PSObject -Property @{
# mashine name
'Mashine name' = $_.Name
#date when edited
'Date' = Get-Date
# resource pull
'pull' = (Get-VM $_.Name | Get-ResourcePool | select-object name).name
#disk where is mashine
'Datastore' = [system.String]::Join(",",($_.Storage.PerDatastoreUsage | %{Get-View $_.Datastore} | %{$_.Name}))
}
}