Improved SSD Detection During Task Sequences

Lots of you will be familiar with my script I posted last year to enable the detection of solid state disks during a task sequence. I have had much success by tweaking the script in different environments depending on the drive. In this post I will walk through a more reliable way to detect the presence of SSD drives in your task sequences.

Within Windows 7 and Windows 8 we can use the Windows Performance Index rating or WinSAT to determine the performance factor of the machine.

We can use WinSAT in a couple of ways to detect your SSD drives and using the built-in capabilities of WinSAT to reliably detect your SSD drives. These methods both use WinSAT, one uses a script in MDT (doesn’t have to be in MDT) and another uses WMI.

Detection via WMI

The first method uses WMI and a full WinSAT test to determine the score of the disk. It is safe to assume from tests that a standard disk will never be higher than 6.9 and SSD disks exceed 7.0 (usually around 8.0 or higher).

To begin we need to run WinSAT in our task sequence. We can do this running a normal run command line task sequence step. The configuration of this step would look like as follows.

WinSAT Assessment

Depending on system performance this will take around 3 or 4 minutes to run. When WinSAT has finished you will find the results in WMI which you can find in the Win32_WinSAT class. For our purposes we will need the DiskScore property. You have two options here, you can either specify a condition on the task sequence step which queries WMI for a disk score above 6.9. This would look something like the following.

Task Sequence Condition

You can also set a task sequence variable after WinSAT has finished which will determine the state of your disk again using the above condition to set the variable and then base your task sequence steps based on the value of the variable. It’s an extra step but will clearly work as well as just running the condition shown above. For the purpose of copy and paste, here is the WMI query.

SELECT * FROM Win32_WinSAT WHERE DiskScore > "6.9"

Scripting

The second method uses a script. As well instead of using the formal method of detection, this still performs a random read write test just like the method above however this method only performs this one test thus making it quicker to execute. If time is important then you can use this method.

You can download the script from my SkyDrive: http://sdrv.ms/133Q8Hl

Safe the file as a .wsf and add it to your MDT toolkit package.

cscript.exe %DeployRoot%/scripts/ZTIDiskType.wsf

This will set a variable called DiskPerf to be the value of the WinSAT results. The difference here is that the following command is ran:

winsat.exe disk -seq -read

The other difference is that running this command does not populate WMI with the value of the test, this only happens when the formal command is executed.

Summary

So here you have it, two improved and more accurate ways to detect your SSD drives. Depending on your requirements and time constraints you can use either method of detection.

Advertisements

Tags: , , , , , , , , , , ,

About Martyn

Martyn is one of the Senior Cloud Architects and DevOps Team Leader at one of the worlds leading Cloud Transformation Specialists Inframon. Martyn is responsible for the architecture of some of the largest Azure deployments in EMEA and is a advisor to a many businesses on their strategies. Martyn is a regular speaker at Microsoft events and community events on Azure and DevOps, giving his insight to a growing number of audiences.

15 responses to “Improved SSD Detection During Task Sequences”

  1. David says :

    thank you for your article !

    Other script

    wscript.echo ZTIDiskType

    Function ZTIDiskType()
    Dim objShell, objExec, sResults, aNameTemp, aName
    Set objShell = CreateObject(“WScript.Shell”)
    Set objExec = objShell.Exec(“winsat.exe disk -seq -read”)

    Do Until objExec.Status = 1
    WScript.Sleep 100
    Loop

    sResults = objExec.StdOut.Readall

    While Instr(sResults,” “) 0
    sResults = replace(sResults,” “,” “)
    Wend
    aNameTemp = Split(sResults, “> Disk Sequential 64.0 Read”)
    aName = Split(Trim(aNameTemp(1)), Chr(13))

    Set objExec = Nothing
    Set objShell = Nothing

    If CInt(Replace(Right(aName(0), 3),”.”,”,”))> 6.9 Then
    ZTIDiskType = “SSD”
    Else
    ZTIDiskType = “HDD”
    End If

    End Function

  2. yannara says :

    It seems that this method works only in Windows 8, in Windows 7 the diskscore result is not saved in WMI, the value will be null. I´ve tested the same procedure on both OS and the result is obvious.

  3. yannara says :

    Hello Martin! Thanks for doing this. The first method, executing WinSAT and using WinSAT class with performance result doesn´t work for us. It seems, that WinSAT class is not created. I get “failed evaluating the condition for the action” and Error code 4119 for those steps, where I set WMI condition.

    I was thinking to try your script which needs to be saved into MDT tookit package, but I don´t understand, what condition or result it will populate. What I should set into step´s conditions then? Thanks.

    • Martyn says :

      It will populate the variable in the script, then you check for the value of the variable.

      • yannara says :

        What variable? What I should set to a step condition, which I would like to run, if the computer has SSD drive. Sorry, but I don´t understand scripting.

      • Martyn says :

        The script assigns the disk performance value to DiskPerf, so use that variable.

  4. G. Bailey says :

    Thanks, this was an awesome find! I needed a vbscript, and your code worked fine. For anyone less familiar, you can use the original core of his code in a vbs script, and just set the value to the function variable to return it to the main script to apply your logic to the results. Worked for my needs anyway.

  5. Jake says :

    Just a quick question, this works when I put it in the deployment task, however, if I wish to run it on Windows 7 clients that are already deployed, how would I go about doing this? I notice that your script requires ZTIUtility, is there a way to find out what is uses and just edit it?

    • Martyn says :

      Hi Jake,

      Well the ZTIUtility is just for MDT, it’s a set of functions allowing access to the task sequence environment. You could use the function as normal just replacing oEnvironment with WScript.Echo or whatever you want to do with it. Something like this (sorry for any formatting problems)…


      Function ZTIDiskType()
      Dim objShell, objExec, sResults, aNameTemp, aName
      Set objShell = CreateObject("WScript.Shell")
      Set objExec = objShell.Exec("winsat.exe disk -seq -read")

      Do Until objExec.Status = 1
      WScript.Sleep 100
      Loop

      sResults = objExec.StdOut.Readall
      aNameTemp = Split(sResults, "> Disk Sequential 64.0 Read")
      aName = Split(Trim(aNameTemp(1)), Chr(13))

      WScript.Echo Right(aName(0), 3)

      Set objExec = Nothing
      Set objShell = Nothing
      End Function

      • Jake says :

        ahh ok, thanks.
        I recon i just need a script that will query the disk stats and write it to the registry (out of WDS). Then i can use some of our software to pick it up and run out a task.

      • Martyn says :

        Yep spot on, you could just use Compliance Items in ConfigMgr as well to pick up the registry key.

      • Jake says :

        ahh!
        Without sounding too much like a fool, how would i go about creating such script?
        I am new to this scripting lark, but i have been tasked with creating one for SSD deployment.
        All i need to do is create a script i can remotley execute or run locally on the PC that will run the WINsat formal and then write the reg key for the disk speed. Any help would be appreciated (:

        Thanks

      • Martyn says :

        It’s not a script, it’s Compliance Items in ConfigMgr. A script would populate a registry key or something like that then Compliance Items would monitor that key for it’s value.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: