Disk size script example

# Allow to execute external scripts
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

# Ignore the certificate check
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false

#import module and get VMs list
Import-Module VMware.VimAutomation.Core
$cred = Get-Credential dgorokhov@vsphere.local
Connect-VIServer nlam0c0avce000.int.tech.altenar.net -cred $cred
$vms=get-vm -Name а120w* | Get-HardDisk | select Parent, capacitygb
$vms | ConvertTo-Csv | Out-File 'C:\temp\vms.csv'
Start-Process 'C:\temp\vms.csv'

Another example

# Allow to execute external scripts
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

# Ignore the certificate check
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false

#import module and get VMs list
Import-Module VMware.VimAutomation.Core
$cred = Get-Credential dgorokhov@vsphere.local
Connect-VIServer nlam0c0avce000.int.tech.altenar.net -cred $cred
2..9 | % { $name += "p001wamb00$_`n" }
get-vm -Name p001wamb002 | Get-VMHost
#2..9 | foreach { $vmname += "p001wamb00$_" }
#Write-Output $vmname
#2..9 | % { $vname += "p001wamb00$_*`n"}
#Write-Output $vname
#foreach ($na in $vname) {
    #Start-Sleep -Seconds 5
    #get-vm -Name $na | Get-VMHost
    #Start-Sleep -Seconds 5
    #Write-Output $na
    #Start-Sleep -Seconds 5
#}

#1..9 | foreach { "servername$_*" }

Last updated

Was this helpful?