# PS_ExecuteCommand

> Executes PowerShell command.

Source: https://docs.capaone.com/capainstaller/vb-scripting-library/powershell-functions/ps-executecommand/  
Product: CapaInstaller — a separate CapaSystems product; do not apply this page to any other.

### Description

Executes PowerShell command  
The result is being added to `<gsWorkstationPath>\Logs\Temp\PSOut.log`  
If execution policy has been set to "Restricted", single Powershell commands can still be executed  
If it is required to perform more than one command, it is recommended to insert the commands into a script and execute them with the function [PS_ExecuteScript](/capainstaller/vb-scripting-library/powershell-functions/ps-executescript/)

:::caution
For some commands, it may be necessary to add extra formatting to sCommand parameter. In the code block, you can see examples of these formats
:::

:::tip
`PS_ExecuteCommand` and [PS_ExecuteScript](/capainstaller/vb-scripting-library/powershell-functions/ps-executescript/) both write their output to the same `<gsWorkstationPath>\Logs\Temp\PSOut.log` file, so each run overwrites the previous one. If you need to keep a history of the output, create a folder such as `<gsWorkstationPath>\Logs\PowerShell` and copy `PSOut.log` there under a more descriptive name after each run. Alternatively, consider building the logic as a PowerPack instead, which can handle logging on its own.
:::

### Syntax

PS_ExecuteCommand(sCommand) As Boolean

### Parameters

#### sCommand (String)

Powershell command that should be executed

### Example

**VBScript**

```vb
If bStatus Then bStatus = PS_ExecuteCommand("Stop-process -processname notepad")

If bStatus Then bStatus = PS_ExecuteCommand("& {Stop-process -processname notepad}")
```

[Scripting Guidelines](/capainstaller/vb-scripting-library/scripting-guidelines/)

### Related functions

[Constants](/capainstaller/vb-scripting-library/addendum/constants/) [Package Property](/capainstaller/vb-scripting-library/addendum/package-property/) [Variables](/capainstaller/vb-scripting-library/addendum/variables/)
