我正在尝试使用set-itemproperty将项添加到:HKLM:\ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Setup \ Installation Sources
$InstallationSources = Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup" -Name "Installation Sources"
$test = $InstallationSources."Installation Sources" + "C:\Test\I386"
Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup" -Name "Installation Sources" "$test"
我可以回复$ test,它看起来很好,最后添加了几行路径 . 但是当我实际使用set-itempproperty时,它会将所有内容整理成一行,但这不起作用 . 每条路径都需要有自己的路线 . 甚至不传递手动添加的换行符(即:“`nC:\ Test \ I386”) . 想法?
谢谢
2 回答
如果要保留换行符,请确保注册表值的类型为MultiString,否则注册表将不允许换行符AFAICT,例如:
$ test是一个字符串数组,当你说:时,powershell会自动将它们连接在一起
您需要自己进行连接,提供正确的分隔符 . 即: