0

我应该首先强调我在 PowerShell 方面的经验非常非常少,如果这是用户错误,我深表歉意。

https://docs.microsoft.com/en-us/troubleshoot/developer/browsers/administration/k-12-assessments-reports-apps-background复制命令后,我在步骤 4 中一直遇到 Unexpected Token 错误。这个是代码,以及错误:

$registryPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\PreLaunch\Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge" $Name = "Enabled" $value = "0" New-Item -Path $registryPath -Force | Out-Null New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null At line:1 char:138

  • ... ch\Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge" $Name = "启用 ...
  •                                                         ~~~~~
    

表达式或语句中出现意外的标记“$Name”。在行:1 字符:156

  • ... oftEdge_8wekyb3d8bbwe!MicrosoftEdge" $Name = "Enabled" $value = "0" N ...
  •                                                        ~~~~~~
    

表达式或语句中出现意外的标记“$value”。在行:1 字符:169

  • ... d8bbwe!MicrosoftEdge" $Name = "Enabled" $value = "0" New-Item -Path $ ...
  •                                                      ~~~~~~~~
    

表达式或语句中出现意外的标记“New-Item”。+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : UnexpectedToken

我尝试过处理一些事情并摆脱了一些错误,但不是所有错误。任何帮助将不胜感激!

4

1 回答 1

2

该文档文章的示例格式已损坏,它隐藏了几个换行符:

$registryPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\PreLaunch\Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge"
$Name = "Enabled"
$value = "0"
New-Item -Path $registryPath -Force | Out-Null
New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
于 2022-01-24T16:09:20.483 回答