How to set the StorPort BusyRetryCount registry value using PowerShell

Summary

This script modifies the BusyRetryCount registry value located at HKLM\System\CurrentControlSet\Enum\SCSI\<device>\<instance>\Device Parameters\StorPort

For more information about this value, please see the following article:
An updated StorPort storage driver is available for Windows Server 2003
http://support.microsoft.com/kb/932755

For more information about how to write scripts for Windows PowerShell, visit the following Microsoft website:
General information about how to write scripts for Windows PowerShell

Registry information

Important This section, method, or task contains steps that tell you how to modify the registry. However, serious problems might occur if you modify the registry incorrectly. Therefore, make sure that you follow these steps carefully. For added protection, back up the registry before you modify it. Then, you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click the following article number to view the article in the Microsoft Knowledge Base:
322756  How to back up and restore the registry in Windows


The vendor string variable is used to restrict the value change to a subset of disks matching a specific vendor's identifier. Check the registry for the Disk&Ven_ string to verify what value should be used.

$BusyRetry = 0
$vendor = Read-Host "Enter Vendor String"
$devIDs = Get-ChildItem "HKLM:\SYSTEM\CurrentControlSet\Enum\SCSI\Disk*Ven_$vendor*\*\Device Parameters\"

foreach ($id in $devIDs)
{
$error.Clear()
$regpath = $id.PSPath + "\StorPort\"
Set-ItemProperty -path $regpath -Name BusyRetryCount -Value $BusyRetry -ErrorAction SilentlyContinue

if ($error) # didn't find the path, create it and try again
{
New-Item -Path $id.PSPath -Name StorPort
Set-ItemProperty -path $regpath -Name BusyRetryCount -Value $BusyRetry -ErrorAction SilentlyContinue
$error.Clear()
}

Get-ItemProperty -Path $regpath -Name BusyRetryCount -ErrorAction SilentlyContinue | Select BusyRetryCount | fl | Out-String -Stream
}


Propriétés

ID d'article : 2848785 - Dernière mise à jour : 13 mai 2013 - Révision : 1

Commentaires