Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Bug: CommandNotFoundException for SystemSettingsAdminFlows breaks script on line 1069

已关闭 适合新手
#250 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
74/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
powershell

调研方向

从 PowerShell 脚本的第 1069 行开始,在 SystemSettingsAdminFlows 不可用时重现该故障。检查 issue 中提到的其他 Get-Command 用法是否存在相同的故障模式。完成的标准是:Edge AI 删除阶段跳过缺失的命令,并在不产生未处理的 CommandNotFoundException 的情况下继续执行。

由索引模型根据 Issue 内容生成。

描述

bug

Title: Script crashes during Edge AI removal: Get-Command SystemSettingsAdminFlows throws CommandNotFoundException (line 1069)

Describe the bug

The script crashes at line 1069 during the Edge AI removal phase with a CommandNotFoundException.

The script checks for SystemSettingsAdminFlows like this:

if (Test-Path (get-command SystemSettingsAdminFlows).Source) {

If SystemSettingsAdminFlows is missing from the system (e.g. it was previously removed or debloated), Get-Command raises an error, and the script stops before Test-Path can evaluate to $false. Most likely the error becomes terminating because of $ErrorActionPreference = 'Stop' set in the script.

Steps to reproduce
  1. Use a system where SystemSettingsAdminFlows.exe is missing or unavailable in PATH.
  2. Run the script and proceed to the Edge AI removal phase.
  3. The script fails at line 1069.
Expected behavior

If SystemSettingsAdminFlows is not found, the script should skip this step and continue.

Actual behavior

The script terminates with an unhandled error.

Error log
get-command : Имя "SystemSettingsAdminFlows" не распознано как имя командлета, функции, файла сценария или выполняемой программы. Проверьте правильность написания имени, а также наличие и правильность пути, после чего повторите попытку.
строка:1069 знак:20
+ if (Test-Path (get-command SystemSettingsAdminFlows).Source) {
+ CategoryInfo : ObjectNotFound: (SystemSettingsAdminFlows:String) [Get-Command], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.GetCommandCommand
Suggested fix

Option 1 (minimal): suppress the error and check the result.

$cmd = Get-Command SystemSettingsAdminFlows -CommandType Application -ErrorAction SilentlyContinue
if ($cmd) {
    # Proceed with execution
}

Option 2 (most predictable): check the file by its full path, without depending on PATH.

$exe = Join-Path $env:SystemRoot 'System32\SystemSettingsAdminFlows.exe'
if (Test-Path -LiteralPath $exe) {
    # Proceed with execution
}

-CommandType Application excludes functions and aliases, whose .Source can be empty or a module name, so the extra Test-Path is not needed in Option 1.

Additional notes

Other Get-Command ...).Source calls elsewhere in the script may have the same problem when a component was already removed. It's worth auditing all Get-Command usages and adding -ErrorAction SilentlyContinue or a full-path check.

Environment
  • OS: Windows 11 25h2
  • PowerShell: 5.1
  • Script version / commit: Latest as of 30.09.2026
主要语言
PowerShell
星标
13.4k
派生
470
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

zoicware/RemoveWindowsAI 的其他 Issue

查看 zoicware/RemoveWindowsAI 的全部 Issue

相似的 Issue

更多 Operating Systems Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。