Skip to content

Instantly share code, notes, and snippets.

@a73xsh
Created September 18, 2017 12:35
Show Gist options
  • Save a73xsh/d6d01a1d9139de8c49a57da236ff1e02 to your computer and use it in GitHub Desktop.
Save a73xsh/d6d01a1d9139de8c49a57da236ff1e02 to your computer and use it in GitHub Desktop.
Get VM on Vmware datastore
$report = @()
$VMs = Get-datastore | Where {$_.name -like '*DSName*' -or $_.name -like '*DSName*'} | Get-VM
Foreach ($VM in $VMs){
$line = $VM | Select Name, @{N="vCPU";E={($_).NumCpu}}, @{N="Memory (GB)";E={($_).MemoryGB}}, @{N="Cluster";E={Get-Cluster -VM $_}}, @{N="Folder";E={$_.folder}}, @{N="Network";E={$_.Networkadapters.NetworkName}}
$report += $line
}
$report | Export-csv C:\temp\VMList.csv -NoTypeInformation -UseCulture
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment