I’m sorry to announce that I won’t be able to post anything until the beginning of October. But I will be back, so please keep me in your RSS feed or check back here in a month. I’ll be back full-force, with more awesome one-liners, helpful scripts and fantastic functions!

Here’s a one-liner to show off to your colleagues. What do you do when somebody asks you for a printed overview of the top-twenty volumes on your virtual servers with the least free disk space?

You fire up your trusty Powershell of course! You type a single line of code, press enter and tell them to check the printer. How cool is that?

Get-VM | Where { $_.PowerState -eq “PoweredOn” } | Get-VMGuest | Select VmName -ExpandProperty Disks | Select VmName, Path, @{N=”MBFree”;E={[math]::Round((($_.FreeSpace)/1MB),2)}} | Sort MBFree | Select -First 20 | Format-Table -AutoSize | Out-Printer

Very cool indeed!

See you next month!

Hugo

»crosslinked«

Tagged with:
 

6 Responses to Posting Pause (plus bonus oneliner)

  1. Sumit Gupta says:

    its too good…

  2. Andrea says:

    Select-Object : Cannot expand property “Disks” because it has nothing to expand
    .
    At line:1 char:72
    + Get-VM | Where { $_.PowerState -eq “PoweredOn” } | Get-VMGuest | Select <<<<
    VmName -ExpandProperty Disks | Select VmName, Path, @{N=”MBFree”;E={[math]::Ro
    und((($_.FreeSpace)/1MB),2)}} | Sort MBFree | Select -First 20 | Format-Table –
    AutoSize

  3. rerninhibeBaH says:

    Nothing seems to be easier than seeing someone whom you can help but not helping.
    I suggest we start giving it a try. Give love to the ones that need it.
    God will appreciate it.

  4. @xcud says:

    fyi, I featured this one-liner in another PowerWF video http://www.youtube.com/watch?v=bLrRROKFcJE (PowerScripter Integration). Credit given.

    Thanks again.

  5. István Sándor says:

    $disks = Get-VMGuest -VM | select VmName -ExpandProperty Disks
    #it works well if a VM has only one vDisk
    #If a VM has more than one disk, necessary this:
    foreach($vmd in $disks){
    $row = “” | select Name, capacity, FreeSpace
    $row.name = $vmd.VmName
    $row.FreeSpace = $vmd.FreeSpace
    $row.capacity = $vmd.Capacity
    }

Leave a Reply