MOL PS Toolmaking: where is Lab 4.6 file?

This topic contains 1 reply, has 1 voice, and was last updated by  Jeff Taylor 2 days, 14 hours ago.

  • Author
    Posts
  • #84269

    Jeff Taylor
    Participant

    the advice is "grab the file from Morelunches" but it is not included in the tool-codelistings.zip downloaded.

  • #84271

    Jeff Taylor
    Participant

    I typed it out (it works) but found some typos in the original (There was no ` after {$OK=$True})

    Function Get-DiskInfo {
        Param (
            [string]$computerName='localhost',[int]$MinimumFreepercent=10
        )
            $disks=Get-WmiObject -Class Win32_Logicaldisk -Filter "Drivetype=3"
                foreach ($disk in $disks) {$perFree=($disk.FreeSpace/$disk.Size)*100;
                if ($perFree -ge $MinimumFreepercent) {$OK=$True}`
                else {$OK=$False};$disk|Select DeviceID,VolumeName,Size,FreeSpace,`
                @{name="OK";Expression={$OK}}
    }}
    Get-DiskInfo

    Does this look like acceptable formatting per the book?

You must be logged in to reply to this topic.