The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,861 other subscribers

Posts Tagged ‘possible’

Some links on getting the most recent defragmentation time of a Windows volume

Posted by jpluimers on 2026/02/25

This worked on the built-in Windows PowerShell to get the recommendation status:

$volume = Get-WmiObject -Class Win32_Volume -Filter "DriveLetter = 'C:'"
$analysis = $volume.DefragAnalysis()
$analysis.DefragAnalysis
$analysis.DefragRecommended

Without elevation token, $analysis.DefragAnalysis will be empty and $analysis.DefragRecommended will return False, but elevated it will return the analysis data and  $analysis.DefragRecommended will return False or True depending on the analysis result.,

And this gets the most recent defragmentation action from the event-log:

Read the rest of this entry »

Posted in CommandLine, Development, PowerShell, Scripting, Software Development | Tagged: | Leave a Comment »