{"record":{"id":"9f2e1244d87510e3","repo":"google-gemini/gemini-cli","slug":"powershell-execution-failed-with-status-res-status-res","errorCode":null,"errorMessage":"PowerShell execution failed with status ${res.status}: ${res.stderr || res.stdout}","messagePattern":"PowerShell execution failed with status (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/utils/security.ts","lineNumber":337,"sourceCode":"        '-NoProfile',\n        '-NonInteractive',\n        '-ExecutionPolicy',\n        'Bypass',\n        '-EncodedCommand',\n        encodedScript,\n      ],\n      { encoding: 'utf-8', timeout: 5000 },\n    );\n\n    if (res.error) {\n      if ((res.error as NodeJS.ErrnoException).code === 'ETIMEDOUT') {\n        throw new Error(`Security validation timed out after 5000ms`);\n      }\n      throw res.error;\n    }\n\n    if (res.status !== 0) {\n      throw new Error(\n        `PowerShell execution failed with status ${res.status}: ${res.stderr || res.stdout}`,\n      );\n    }\n\n    const batchResults = parseWindowsBatchSecurityOutput(\n      res.stdout ?? '',\n      uncached,\n    );\n\n    for (const p of uncached) {\n      const parsed = batchResults.get(p) ?? {};\n      let isDir = false;\n      try {\n        isDir = fsSync.statSync(p).isDirectory();\n      } catch {\n        // Leave isDir false if stat fails\n      }\n      const result = formatWindowsSecurityResult(parsed, p, isDir);","sourceCodeStart":319,"sourceCodeEnd":355,"githubUrl":"https://github.com/google-gemini/gemini-cli/blob/6a466a7e2fe2b1255752c1e74f69b31f0216084d/packages/core/src/utils/security.ts#L319-L355","documentation":"The PowerShell security-validation script exited with a nonzero status, meaning the batch path check itself failed (script error, bad input, or environment problem) rather than the paths being insecure. Its exit code and captured stderr/stdout are embedded in the message.","triggerScenarios":"Thrown at packages/core/src/utils/security.ts:337 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect res.stderr/res.stdout in the message for the script's error output","Verify the PowerShell path and execution policy on the machine","Check that the input paths are well-formed for the batch script"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6a466a7e2fe2b1255752c1e74f69b31f0216084d","analyzedAt":"2026-09-16T18:14:43.978Z","contentChangedAt":"2026-09-16T18:14:43.978Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}