github.com/aspring/packer@v0.8.1-0.20150629211158-9db281ac0f89/website/source/docs/provisioners/powershell.html.markdown (about) 1 --- 2 layout: "docs" 3 page_title: "PowerShell Provisioner" 4 description: |- 5 The shell Packer provisioner provisions machines built by Packer using shell scripts. Shell provisioning is the easiest way to get software installed and configured on a machine. 6 --- 7 8 # PowerShell Provisioner 9 10 Type: `powershell` 11 12 The PowerShell Packer provisioner runs PowerShell scripts on Windows machines. 13 It assumes that the communicator in use is WinRM. 14 15 ## Basic Example 16 17 The example below is fully functional. 18 19 ```javascript 20 { 21 "type": "powershell", 22 "inline": ["dir c:\\"] 23 } 24 ``` 25 26 ## Configuration Reference 27 28 The reference of available configuration options is listed below. The only 29 required element is either "inline" or "script". Every other option is optional. 30 31 Exactly _one_ of the following is required: 32 33 * `inline` (array of strings) - This is an array of commands to execute. 34 The commands are concatenated by newlines and turned into a single file, 35 so they are all executed within the same context. This allows you to 36 change directories in one command and use something in the directory in 37 the next and so on. Inline scripts are the easiest way to pull off simple 38 tasks within the machine. 39 40 * `script` (string) - The path to a script to upload and execute in the machine. 41 This path can be absolute or relative. If it is relative, it is relative 42 to the working directory when Packer is executed. 43 44 * `scripts` (array of strings) - An array of scripts to execute. The scripts 45 will be uploaded and executed in the order specified. Each script is executed 46 in isolation, so state such as variables from one script won't carry on to 47 the next. 48 49 Optional parameters: 50 51 * `binary` (boolean) - If true, specifies that the script(s) are binary 52 files, and Packer should therefore not convert Windows line endings to 53 Unix line endings (if there are any). By default this is false. 54 55 * `environment_vars` (array of strings) - An array of key/value pairs 56 to inject prior to the execute_command. The format should be 57 `key=value`. Packer injects some environmental variables by default 58 into the environment, as well, which are covered in the section below. 59 60 * `execute_command` (string) - The command to use to execute the script. 61 By default this is `powershell "& { {{.Vars}}{{.Path}}; exit $LastExitCode}"`. 62 The value of this is treated as [configuration template](/docs/templates/configuration-templates.html). 63 There are two available variables: `Path`, which is 64 the path to the script to run, and `Vars`, which is the list of 65 `environment_vars`, if configured. 66 67 * `elevated_user` and `elevated_password` (string) - If specified, 68 the PowerShell script will be run with elevated privileges using 69 the given Windows user. 70 71 * `remote_path` (string) - The path where the script will be uploaded to 72 in the machine. This defaults to "/tmp/script.sh". This value must be 73 a writable location and any parent directories must already exist. 74 75 * `start_retry_timeout` (string) - The amount of time to attempt to 76 _start_ the remote process. By default this is "5m" or 5 minutes. This 77 setting exists in order to deal with times when SSH may restart, such as 78 a system reboot. Set this to a higher value if reboots take a longer 79 amount of time. 80 81 * `valid_exit_codes` (list of ints) - Valid exit codes for the script. 82 By default this is just 0.