Repository: incubator-brooklyn Updated Branches: refs/heads/master 80bf72873 -> c2494dce8
Windows scripting documentation updates - $ErrorActionPreference - powershell commands limitations Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/0e3953b2 Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/0e3953b2 Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/0e3953b2 Branch: refs/heads/master Commit: 0e3953b2ab47fb331ac3823778626ee36cce272f Parents: f1d90c6 Author: Valentin Aitken <[email protected]> Authored: Mon Oct 19 10:16:27 2015 +0300 Committer: Valentin Aitken <[email protected]> Committed: Mon Oct 19 14:54:37 2015 +0300 ---------------------------------------------------------------------- docs/guide/yaml/winrm/index.md | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0e3953b2/docs/guide/yaml/winrm/index.md ---------------------------------------------------------------------- diff --git a/docs/guide/yaml/winrm/index.md b/docs/guide/yaml/winrm/index.md index a29d75a..e09564e 100644 --- a/docs/guide/yaml/winrm/index.md +++ b/docs/guide/yaml/winrm/index.md @@ -148,12 +148,26 @@ circumstances. It is therefore advisable to follow the guidelines below. Upload this (e.g. by including it in the `files.preinstall` configuration). For the configuration of the given command, execute the file.* -For Powershell files, consider including the line below at the start of the file. -Without this, it defaults to "continue" which means that if a command in the Powershell file fails -then it will continue and return an exit code based on only the final command. +When you have a command inside the powershell script which want to report its non zero exiting, +please consider adding a check for its exit code after it. +Example: + + C:\install.exe + If ($lastexitcode -ne 0) { + exit $lastexitcode + } + +For Powershell files, consider including $ErrorActionPreference = "Stop" +at the start of the file. +`$ErrorActionPreference` Determines how Windows PowerShell responds to a non-terminating +error (an error that does not stop the cmdlet processing) at the +command line or in a script, cmdlet, or provider, such as the +errors generated by the Write-Error cmdlet. +https://technet.microsoft.com/en-us/library/hh847796.aspx + See [Incorrect Exit Codes](#incorrect-exit-codes) under Known Limitations below. ### Executing Scripts From Batch Commands @@ -424,9 +438,14 @@ is not respected. For example, the command below will receive an exit code of 0. ##### Non-zero Exit Code Returned as One -If a batch or Powershell file exits with an exit code greater than one (or negative), this may -be reported as 1 over WinRM. For example, if a batch file ends with `exit /B 3`, the WinRM -result from executing that file will be 1. +If a batch or Powershell file exits with an exit code greater than one (or negative), this will +be reported as 1 over WinRM. + +We advise you to use native commands (non-powershell ones) since executing it as a native command +will return the exact exit code rather than 1. +For instance if you have installmssql.ps1 script use `install.command: powershell -command "C:\\installmssql.ps1"` +rather than using `install.powershell.command: "C:\\installmssql.ps1"` +The first will give you an exact exit code rather than 1 ### PowerShell "Preparing modules for first use"
