【发布时间】:2022-06-17 23:57:37
【问题描述】:
我一直在尝试将此 PowerShell 脚本部署到我的一个测试单元,这涉及通过更改某些注册表项的值来更改 Windows 11 中的任务栏布局。当它通过 Intune 进行部署时,它返回成功,但未进行任何更改。该脚本在手动完成时也是成功的。有些东西我错过了,但我无法弄清楚。
$registryPath1 = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Search"
$registryPath2 = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
$registryPath3 = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
$name1 = "SearchboxTaskbarMode"
$name2 = "ShowTaskViewButton"
$name3 = "TaskbarAl"
$value1 = "0"
$value2 = "0"
$value3 = "0"
IF(!(Test-Path $registrypath1))
{
New-Item -Path $registryPath1 -Force | Out-Null
Set-ItemProperty -Path $registryPath1 -Name $name1 -Value $value1 `
}
ELSE {
Set-ItemProperty -Path $registryPath1 -Name $name1 -Value $value1 `
}
IF(!(Test-Path $registryPath2))
{
New-Item -Path $registryPath2 -Force | Out-Null
Set-ItemProperty -Path $registryPath2 -Name $name2 -Value $value2 `
}
ELSE {
Set-ItemProperty -Path $registryPath2 -Name $name2 -Value $value2 `
}
IF(!(Test-Path $registryPath3))
{
New-Item -Path $registryPath3 -Force | Out-Null
Set-ItemProperty -Path $registryPath3 -Name $name3 -Value $value3 `
}
ELSE {
Set-ItemProperty -Path $registryPath3 -Name $name3 -Value $value3 `
}`
【问题讨论】:
-
这些是当前用户注册表项吗?这只会影响脚本运行的用户,除非它是登录脚本。您可以使用 $error.count 退出以查看是否有任何异常,或将其记录下来。用户可能还需要重新登录。
-
脚本手动工作正常,只是通过 Intune 似乎没有确认任何更改。在几个单位上试过这个。
-
如果 intune 以系统用户身份运行,那么它只会影响系统用户。您可以尝试将其作为组策略用户登录脚本,或者如果 intune 有类似的东西。
标签: powershell intune