Hi Guy's
I have been trying to write a script that will output the name of a vm and the datastore its located on. This is what i have written so far:
$cred = Get-Credential
Connect-VIServer xxx.domain.com -Credential $cred
$datastore = Get-Datastore | select Name
foreach ($objitem in $datastore)
{
Get-VM | select Name
Write-Host "This is located on" $objitem.Name
}
Disconnect-VIServer -Confirm:$false
This script appears to be nearly there but im not getting the names of the datastore. Ideally i'd expect something like:
Name: VM1 Datasore: Lun01
Name: VM2 Datasore: Lun02
Name: VM3 Datasore: Lun03
Can anybody advise?
Regards
Mr G