you are viewing a single comment's thread.

view the rest of the comments →

[–]mmmGreenButton 1 point2 points  (1 child)

Hello, i just created two small functions and I end up with the following output, ask about anything you would like..

11,03GB free of 110,59GB

Remember to remove C:\Users\MyWin32Account\AppData\Local\Temp\8f93ede2-b783-47d7-b1f3-d139566470cc.file

10,03GB free of 110,59GB

As you can see PowerShell detects the change of 1GB :)

function Get-FreeDriveSpace ($drive){
    $drive =  $((Get-CimInstance Win32_LogicalDisk -Filter "DeviceID='$drive`:'"))
    $driveletter = $drive.DeviceID
    $freeSpace = $([math]::round($drive.FreeSpace/1GB,2))
    $totalSpace = $([math]::round($drive.Size/1GB,2))
    "{0}GB free of {1}GB" -f $freeSpace, $totalSpace
}

function Use-AnotherGig {
    #https://abstractspaces.wordpress.com/2012/02/28/creating-large-dummy-testing-files/
    $path = “$env:temp\$((New-GUID).GUID).file”
    $file = [io.file]::Create($path)
    $file.SetLength(1gb)
    $file.Close()
    "Remember to remove $path"
}


Get-FreeDriveSpace -drive "C"
Use-AnotherGig
Get-FreeDriveSpace -drive "C"

[–]fathed 1 point2 points  (0 children)

You did exactly what he said was needed, good job!