{
  "_id": "powershell-utils",
  "maintainers": [
    {
      "name": "sindresorhus",
      "email": "sindresorhus@gmail.com"
    }
  ],
  "keywords": [
    "powershell",
    "windows",
    "execute",
    "command",
    "shell",
    "console",
    "terminal",
    "cli",
    "spawn",
    "exec",
    "utilities"
  ],
  "dist-tags": {
    "latest": "0.2.0"
  },
  "author": {
    "name": "Sindre Sorhus",
    "email": "sindresorhus@gmail.com",
    "url": "https://sindresorhus.com"
  },
  "_rev": "2-d9cdd14580572a5024381dc40f72b2a2",
  "description": "Utilities for executing PowerShell commands",
  "readme": "# powershell-utils\n\n> Utilities for executing PowerShell commands\n\n## Install\n\n```sh\nnpm install powershell-utils\n```\n\n## Usage\n\n```js\nimport {executePowerShell, powerShellPath} from 'powershell-utils';\n\nconst {stdout} = await executePowerShell('Get-Process');\nconsole.log(stdout);\n\nconsole.log(powerShellPath());\n//=> 'C:\\\\Windows\\\\System32\\\\WindowsPowerShell\\\\v1.0\\\\powershell.exe'\n```\n\n## API\n\n### powerShellPath()\n\nReturns: `string`\n\nGet the PowerShell executable path on Windows.\n\n```js\nimport {powerShellPath} from 'powershell-utils';\n\nconst psPath = powerShellPath();\n//=> 'C:\\\\Windows\\\\System32\\\\WindowsPowerShell\\\\v1.0\\\\powershell.exe'\n```\n\n### canAccessPowerShell()\n\nReturns: `Promise<boolean>`\n\nCheck if PowerShell is accessible on Windows.\n\nThis checks if the PowerShell executable exists and has execute permissions. Useful for detecting restricted environments where PowerShell may be disabled by administrators.\n\n```js\nimport {canAccessPowerShell} from 'powershell-utils';\n\nif (await canAccessPowerShell()) {\n\tconsole.log('PowerShell is available');\n} else {\n\tconsole.log('PowerShell is not accessible');\n}\n```\n\n### executePowerShell(command, options?)\n\nReturns: `Promise<{stdout: string, stderr: string}>`\n\nExecute a PowerShell command.\n\n```js\nimport {executePowerShell} from 'powershell-utils';\n\nconst {stdout} = await executePowerShell('Get-Process');\nconsole.log(stdout);\n```\n\n#### command\n\nType: `string`\n\nThe PowerShell command to execute.\n\n#### options\n\nType: `object`\n\nThe below option and also all options in Node.js [`child_process.execFile()`](https://nodejs.org/api/child_process.html#child_processexecfilefile-args-options-callback) are supported.\n\n##### powerShellPath\n\nType: `string`\\\nDefault: `powerShellPath()`\n\nPath to PowerShell executable. Useful when calling from WSL or when PowerShell is in a non-standard location.\n\n##### encoding\n\nType: `string`\\\nDefault: `'utf8'`\n\nCharacter encoding for stdout and stderr.\n\n### executePowerShell.argumentsPrefix\n\nType: `string[]`\n\nStandard PowerShell arguments that prefix the encoded command: `['-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-EncodedCommand']`\n\nExposed for debugging or for advanced use cases where you need to customize the arguments. For most cases, use `createArguments()` instead.\n\n### executePowerShell.encodeCommand(command)\n\nReturns: `string`\n\nEncode a PowerShell command as Base64 UTF-16LE.\n\nThis encoding prevents shell escaping issues and ensures complex commands with special characters are executed reliably.\n\n#### command\n\nType: `string`\n\nThe PowerShell command to encode.\n\n```js\nimport {executePowerShell} from 'powershell-utils';\n\nconst encoded = executePowerShell.encodeCommand('Get-Process');\n```\n\n### executePowerShell.escapeArgument(value)\n\nReturns: `string`\n\nEscape a string argument for use in PowerShell single-quoted strings.\n\n#### value\n\nType: `unknown`\n\nThe value to escape.\n\n```js\nimport {executePowerShell} from 'powershell-utils';\n\nconst escaped = executePowerShell.escapeArgument(\"it's a test\");\n//=> \"'it''s a test'\"\n\n// Use in command building\nconst command = `Start-Process ${executePowerShell.escapeArgument(appName)}`;\n```\n\n### executePowerShell.createArguments(command)\n\nReturns: `string[]`\n\nCreate the full arguments array for PowerShell execution.\n\nCombines `argumentsPrefix` with the encoded command. Useful when using `spawn()`, `execFile()`, or other process execution methods.\n\n#### command\n\nType: `string`\n\nThe PowerShell command.\n\n```js\nimport {spawn} from 'node:child_process';\nimport {powerShellPath, executePowerShell} from 'powershell-utils';\n\nconst args = executePowerShell.createArguments('Get-Process');\nspawn(powerShellPath(), args);\n```\n\n### executePowerShellSync(command, options?)\n\nReturns: `string`\n\nExecute a PowerShell command synchronously.\n\n```js\nimport {executePowerShellSync} from 'powershell-utils';\n\nconst stdout = executePowerShellSync('Get-Process');\nconsole.log(stdout);\n```\n\n#### command\n\nType: `string`\n\nThe PowerShell command to execute.\n\n#### options\n\nType: `object`\n\nThe below option and also all options in Node.js [`child_process.execFileSync()`](https://nodejs.org/api/child_process.html#child_processexecfilesyncfile-args-options) are supported.\n\n##### powerShellPath\n\nType: `string`\\\nDefault: `powerShellPath()`\n\nPath to PowerShell executable.\n\n##### encoding\n\nType: `string`\\\nDefault: `'utf8'`\n\nCharacter encoding for the output.\n",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/sindresorhus/powershell-utils.git"
  },
  "bugs": {
    "url": "https://github.com/sindresorhus/powershell-utils/issues"
  },
  "license": "MIT",
  "versions": {
    "0.1.0": {
      "name": "powershell-utils",
      "version": "0.1.0",
      "keywords": [
        "powershell",
        "windows",
        "execute",
        "command",
        "shell",
        "console",
        "terminal",
        "cli",
        "spawn",
        "exec",
        "utilities"
      ],
      "author": {
        "url": "https://sindresorhus.com",
        "name": "Sindre Sorhus",
        "email": "sindresorhus@gmail.com"
      },
      "license": "MIT",
      "_id": "powershell-utils@0.1.0",
      "maintainers": [
        {
          "name": "sindresorhus",
          "email": "sindresorhus@gmail.com"
        }
      ],
      "homepage": "https://github.com/sindresorhus/powershell-utils#readme",
      "bugs": {
        "url": "https://github.com/sindresorhus/powershell-utils/issues"
      },
      "dist": {
        "shasum": "5a42c9a824fb4f2f251ccb41aaae73314f5d6ac2",
        "tarball": "https://archive.ito.gov.ir/npm/_packages/powershell-utils/-/powershell-utils-0.1.0.tgz",
        "fileCount": 5,
        "integrity": "sha512-dM0jVuXJPsDN6DvRpea484tCUaMiXWjuCn++HGTqUWzGDjv5tZkEZldAJ/UMlqRYGFrD/etByo4/xOuC/snX2A==",
        "signatures": [
          {
            "sig": "MEUCIQDJNyNhovKY6yIoG6vV/qk6tH+bRQzdvdAd73Tl58SztgIgR25zFUuUv2uHazOrHGQ2kwS1zgnRMNvDoul9CoZkMKg=",
            "keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
          }
        ],
        "unpackedSize": 9813
      },
      "type": "module",
      "types": "./index.d.ts",
      "engines": {
        "node": ">=20"
      },
      "exports": {
        "types": "./index.d.ts",
        "default": "./index.js"
      },
      "funding": "https://github.com/sponsors/sindresorhus",
      "gitHead": "66187bc2c4a73cf1d85d92836ae6ab70e5c5eb9c",
      "scripts": {
        "test": "xo && ava && tsc index.d.ts --skipLibCheck"
      },
      "_npmUser": {
        "name": "sindresorhus",
        "email": "sindresorhus@gmail.com"
      },
      "repository": {
        "url": "git+https://github.com/sindresorhus/powershell-utils.git",
        "type": "git"
      },
      "_npmVersion": "11.6.1",
      "description": "Utilities for executing PowerShell commands",
      "directories": {},
      "sideEffects": false,
      "_nodeVersion": "20.19.5",
      "_hasShrinkwrap": false,
      "devDependencies": {
        "xo": "^0.59.0",
        "ava": "^6.4.1",
        "typescript": "^5.9.3"
      },
      "_npmOperationalInternal": {
        "tmp": "tmp/powershell-utils_0.1.0_1763194224198_0.8989235522659442",
        "host": "s3://npm-registry-packages-npm-production"
      }
    },
    "0.2.0": {
      "name": "powershell-utils",
      "version": "0.2.0",
      "description": "Utilities for executing PowerShell commands",
      "license": "MIT",
      "repository": {
        "type": "git",
        "url": "git+https://github.com/sindresorhus/powershell-utils.git"
      },
      "funding": "https://github.com/sponsors/sindresorhus",
      "author": {
        "name": "Sindre Sorhus",
        "email": "sindresorhus@gmail.com",
        "url": "https://sindresorhus.com"
      },
      "type": "module",
      "exports": {
        "types": "./index.d.ts",
        "default": "./index.js"
      },
      "sideEffects": false,
      "engines": {
        "node": ">=20"
      },
      "scripts": {
        "test": "xo && ava && tsc index.d.ts --skipLibCheck"
      },
      "keywords": [
        "powershell",
        "windows",
        "execute",
        "command",
        "shell",
        "console",
        "terminal",
        "cli",
        "spawn",
        "exec",
        "utilities"
      ],
      "devDependencies": {
        "ava": "^6.4.1",
        "typescript": "^5.9.3",
        "xo": "^0.59.0"
      },
      "gitHead": "647dbfb616e3817db95898ab52e1cf1e6931e24d",
      "types": "./index.d.ts",
      "_id": "powershell-utils@0.2.0",
      "bugs": {
        "url": "https://github.com/sindresorhus/powershell-utils/issues"
      },
      "homepage": "https://github.com/sindresorhus/powershell-utils#readme",
      "_nodeVersion": "25.3.0",
      "_npmVersion": "11.7.0",
      "dist": {
        "integrity": "sha512-ZlsFlG7MtSFCoc5xreOvBAozCJ6Pf06opgJjh9ONEv418xpZSAzNjstD36C6+JwOnfSqOW/9uDkqKjezTdxZhw==",
        "shasum": "bb075dcadc1564f3bd80fddda4f0a481ccbdcf36",
        "tarball": "https://archive.ito.gov.ir/npm/_packages/powershell-utils/-/powershell-utils-0.2.0.tgz",
        "fileCount": 5,
        "unpackedSize": 12475,
        "signatures": [
          {
            "keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U",
            "sig": "MEUCIQDsKe3l4qMVUi86s4rapBlA1l5GsamQbylx878mpaeeOgIgAMPYn93D3V5sAi7CwWyvjmalhmt4xsY3kbruup7kAAk="
          }
        ]
      },
      "_npmUser": {
        "name": "sindresorhus",
        "email": "sindresorhus@gmail.com"
      },
      "directories": {},
      "maintainers": [
        {
          "name": "sindresorhus",
          "email": "sindresorhus@gmail.com"
        }
      ],
      "_npmOperationalInternal": {
        "host": "s3://npm-registry-packages-npm-production",
        "tmp": "tmp/powershell-utils_0.2.0_1769312393060_0.6824654007037241"
      },
      "_hasShrinkwrap": false
    }
  },
  "name": "powershell-utils",
  "time": {
    "created": "2025-11-15T08:10:24.197Z",
    "modified": "2026-04-27T09:09:24.502Z",
    "0.1.0": "2025-11-15T08:10:24.411Z",
    "0.2.0": "2026-01-25T03:39:53.218Z"
  },
  "readmeFilename": "readme.md",
  "homepage": "https://github.com/sindresorhus/powershell-utils#readme"
}