我使用的是来自http://www.erichumphrey.com/2011/03/change-sql-startup-parameters-with-powershell/
的脚本$StartupParameter = "PS >Add-SqlServerStartupParameter '-T3226'"
$hklmRootNode = "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server"
$props = Get-ItemProperty "$hklmRootNode\Instance Names\SQL"
$instances = $props.psobject.properties | ?{$_.Value -like 'MSSQL*'} | select Value
$instances | %{
$inst = $_.Value;
$regKey = "$hklmRootNode\$inst\MSSQLServer\Parameters"
$props = Get-ItemProperty $regKey
$params = $props.psobject.properties | ?{$_.Name -like 'SQLArg*'} | select Name, Value
#$params | ft -AutoSize
$hasFlag = $false
foreach ($param in $params) {
if($param.Value -eq $StartupParameter) {
$hasFlag = $true
break;
}
}
if (-not $hasFlag) {
"Adding $StartupParameter"
$newRegProp = "SQLArg"+($params.Count)
Set-ItemProperty -Path $regKey -Name $newRegProp -Value $StartupParameter
} else {
"$StartupParameter already set"
}
}
有人能告诉我是否可以在针对多个不同SQL Server的循环中使用此powershell脚本?如果是这样,我该怎么办呢?