【发布时间】:2015-06-18 15:14:43
【问题描述】:
我有以下将一些注册表项放入一种数组中。我试图弄清楚如何查看这些对象中的每一个,并根据“en-US”或“de-DE”、“it-IT”等的特定字符串值来决定,然后找到该字符串并执行设置文件。
服务器可能安装了多种语言,我想确保它通过每种语言并安装一个设置 - 一旦完成,然后返回并再次查看它并为尚未安装的语言运行另一个设置被剧本感动。
更新:
到目前为止,感谢您的回答,我得到了以下有效的答案。但是我需要能够编写主机说明“运行意大利语设置”之类的内容,并且还可以使用 Start-Process?我正在尝试使用 Start-process 但出现错误:
$ItalianSpellingHotfix = "C:\Temp\IE11_Spelling_Hyphenation\IE-Spelling-it.msu"
$langInstalled = Get-ChildItem -Path hklm:\System\CurrentControlSet\Control\MUI\UILanguages | Select -ExpandProperty PSChildName
switch ($langInstalled)
{
{$_ -match "it-IT"} {start-process c:\windows\system32\wusa.exe $ItalianSpellingHotfix /quiet /norestart}
#{$_ -match "de-DE"} {"Running German Setup"}
#{$_ -match "en-US"} {"Running US English Setup"}
#{$_ -match "es-ES"} {"Running Spanish Setup"}
}
错误:
Start-Process : A positional parameter cannot be found that accepts argument '/quiet'.
At line:9 char:26
+ {$_ -match "it-IT"} {start-process c:\windows\system32\wusa.exe $ItalianSpel ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Start-Process], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.StartProcessCommand
【问题讨论】:
-
您需要遍历
$langInstalled,并且可能应该使用switch语句来检查它是否匹配,而不是if..else
标签: powershell