Disk Performance - Winsat

On all the computers I support I want/need to monitor the performance of all physical disks regurlarly via a Powershell script started via Windows scheduler:

$out = winsat disk -seq -read -drive $laufwerk.deviceid

fails as $out only contains the first line of winsat-output:

Windows-Systembewertungstool

What do I miss or can you recommend another CLI-enabled tool for measuring disk performance?

Many thanks - Michael

I cannot reproduce. On my system I get the full output of winsat in the variable $out.

You may show the complete code or at least the relevant part of it.

The problem only exists if I start the script via Windows scheduler.

If I run it interactively everything ist fine.

Thank - Michael

I think you need to share more of your script and your settings for the scheduled task as I also cannot reproduce the problem. I ran a basic script as a scheduled task and the output file contained the full output.

$out = winsat disk -seq -read -drive G:
$out | Out-File E:\temp\winsat.txt

I did have to select Run with highest privileges, but I’m guessing you have selected that otherwise you wouldn’t even get the title output?

My complete (test-)script is:

$laufwerke = Get-Wmiobject Win32_logicaldisk | Select-Object deviceid,DriveType
foreach ($laufwerk in $laufwerke)
{
   if($laufwerk.DriveType -eq 3)
   {
      $out = winsat disk -seq -read -drive $laufwerk.deviceid -v
	  Set-Content -Path c:\temp\winsat_PS\winsat1.txt -Value $out
	  $out1 = $out.Replace(">", "")
	  
	  Set-Content -Path c:\temp\winsat_PS\winsat2.txt -Value $out1
	  
      $lines = $out1 -split "`n"
	  
	  Set-Content -Path c:\temp\lines.txt -Value $lines

# Durchlaufe jede Zeile
      foreach ($line in $lines)
      {
         if ($line -like "*MB/s*")
         {
            Set-Content -Path c:\temp\winsat_PS\winsat3.txt -Value $line
         }		  
      }
   }
}

winsat1.txt gives me:

Windows-Systembewertungstool
Befehlszeile ‘“C:\WINDOWS\system32\WinSAT.exe” disk -seq -read -drive C: -v’
DWM not running

Could “DWM not running” be the reason for my problem (DWM = Desktop Window Manager)? DWM might not be running in my sheduled task envirronment?

Thanks again - Michael

Your script works fine for me as a scheduled task.

I don’t think DWM would affect it. There’s a separate test for DWM and, while I don’t know for certain, I’m guessing the tool just checks to see if that’s running in case you choose to run that test.

You are overwriting the file each time you loop. Is it possible that the last disk collected by Get-WMIObject is missing or has a problem which is preventing the assessment completing?

I would:

  • Evaluate the output of the Get-WMIObject command.
  • Add some logging so you know which device your script is currently processing.
  • Use Add-Content to append the data to the files instead of overwriting each time.
2 Likes

I further explored:

The script works fine if I start the scheduled task with the setting “only execute if the user is logged on”. It does not give winsat results if I start the scheduled task with the setting “execute independently from the user login”. In both cases I start the scheduled task with highest privileges.

My standard unfortunately is the second as I want to have the script running independently from the user logged in. For this purpose I defined on every client a local administrator account “ladmin” as task user for whom winsat obviously does not give any result!?

My way out (?): Integrate the script into the login procedure (most of my users have admin priviliges). Would you recommend another solution?

Thanks again - Michael

Why not running it with the local SYSTEM account?

You can’t see the forest for the trees: That’s it

Many thanks (this saved me some work and furzher headache) - Michael

Sounded well but: winsat obviously only works as desired in scheduled tasks if this task runs under the “real” user and “only execute if this user is logged in”. In my business case I cannot afford this so I have to reswitch to “Integrate the script into the login procedure (most of my users have admin privileges)” - Or would you recommend another solution?

Thanks - Michael

It does look like this is a limitation of WinSAT.

When WinSAT runs, it writes a log file to C:\Windows\Performance\WinSAT

When the scheduled task is set to ‘Run whether user is logged on or not’ the following DirectX error is logged before the process exits.

4322171 (8328) - d3d\dx9misc.cpp:1035: HRESULT = 8876086c
4322171 (8328) - d3d\dx9misc.cpp:1035: Error: Unable to create the D3D device
4322171 (8328) - d3d\dx9misc.cpp:1035: Error: Unable to check the capabilities of the video card because a d3d device could not be created
4322171 (8328) - exe\processwinsaterror.cpp:0298: Unspecified error 24 occured.

As previously mentioned with regard to the DWM error, it looks like WinSAT checks all resources, even if it’s only running specific tests.

Probably worth noting that the default WinSAT scheduled task under Microsoft\Windows\Maintenance is set to ‘Run only when a user is logged on’.

1 Like

Thanks for explanation and all your efforts! My solution “Integrate the script into the login procedure” will work as well but the time to explore the reason for this behaviour is “overwhelming”.

Michael