You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+30-28Lines changed: 30 additions & 28 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
-
#powershell
1
+
#powershell
2
2
3
-
####Table of Contents
3
+
####Table of Contents
4
4
5
5
1.[Overview](#overview)
6
6
2.[Module Description - What the module does and why it is useful](#module-description)
@@ -12,20 +12,20 @@
12
12
5.[Limitations - OS compatibility, etc.](#limitations)
13
13
6.[Development - Guide for contributing to the module](#development)
14
14
15
-
##Overview
15
+
##Overview
16
16
17
17
This module adds a new exec provider capable of executing PowerShell commands.
18
18
19
-
##Module Description
19
+
##Module Description
20
20
21
21
Puppet provides a built-in `exec` type that is capable of executing commands. This module adds a `powershell` provider to the `exec` type, which enables `exec` parameters, listed below. This module is particularly helpful if you need to run PowerShell commands but don't know the details about how PowerShell is executed, since you can technically run PowerShell commands in Puppet without the module.
22
22
23
-
##Setup
23
+
##Setup
24
24
25
-
###Setup Requirements
25
+
###Setup Requirements
26
26
This module requires PowerShell to be installed and the `powershell.exe` to be available in the system PATH.
27
27
28
-
###Beginning with powershell
28
+
###Beginning with powershell
29
29
30
30
The powershell module adapts the Puppet [exec](http://docs.puppet.com/references/stable/type.html#exec) resource to run PowerShell commands. To get started, simply install the module and declare 'powershell' in `provider` with the applicable command.
31
31
@@ -36,7 +36,7 @@ exec { 'RESOURCENAME':
36
36
}
37
37
~~~
38
38
39
-
##Usage
39
+
##Usage
40
40
41
41
When using `exec` resources with the `powershell` provider, the `command` parameter must be single-quoted to prevent Puppet from interpolating `$(..)`.
42
42
@@ -77,60 +77,62 @@ $obj.Rename("OtherGuest")
77
77
This has the added benefit of not requiring escaping '$' in the PowerShell code. Note that the files need to have DOS linefeeds or they will not work as expected. One tool for converting UNIX linefeeds to DOS linefeeds is [unix2dos](http://freecode.com/projects/dos2unix).
78
78
79
79
80
-
##Reference
80
+
##Reference
81
81
82
-
####Provider
82
+
####Provider
83
83
* powershell - Adapts the Puppet `exec` resource to run PowerShell commands.
84
84
85
-
####Parameters
85
+
####Parameters
86
86
All parameters are optional.
87
87
88
-
#####`creates`
88
+
#####`creates`
89
89
Specifies the file to look for before running the command. The command will only run if the file doesn't exist. **Note: This parameter will not create a file, it will simpy look for one.** Valid options: A string of the path to the file. Default: Undefined.
90
90
91
-
#####`cwd`
91
+
#####`cwd`
92
92
Sets the directory from which to run the command. Valid options: A string of the directory path. Default: Undefined.
93
93
94
-
#####`command`
94
+
#####`command`
95
95
Specifies the actual PowerShell command to execute. Must either be fully qualified or a search path for the command must be provided. Valid options: String. Default: Undefined.
96
96
97
-
#####`environment`
97
+
#####`environment`
98
98
Sets additional environment variables to set for a command. Valid options: String, or an array of multiple options. Default: Undefined.
99
99
100
-
#####`logoutput`
100
+
#####`logoutput`
101
101
Defines whether to log command output in addition to logging the exit code. If you specify 'on_failure', it only logs the output when the command has an exit code that does not match any value specified by the `returns` attribute. Valid options: 'true', 'false', and 'on_failure'. Default: 'on_failure'.
102
102
103
-
#####`onlyif`
103
+
#####`onlyif`
104
104
Runs the exec only if the command returns 0. Valid options: String. Default: Undefined.
105
105
106
-
#####`path`
106
+
#####`path`
107
107
Specifies the search path used for command execution. Valid options: String of the path, an array, or a semicolon-separated list. Default: Undefined.
108
108
109
-
#####`refresh`
109
+
#####`refresh`
110
110
Refreshes the command. Valid options: String. Default: Undefined.
111
111
112
-
#####`refreshonly`
112
+
#####`refreshonly`
113
113
Refreshes the command only when a dependent object is changed. Used with `subscribe` and `notify`[metaparameters](http://docs.puppet.com/references/latest/metaparameter.html). Valid options: 'true', 'false'. Default: 'false'.
114
114
115
-
#####`returns`
115
+
#####`returns`
116
116
Lists the expected return code(s). An error will be returned if the executed command returns something else. Valid options: An array of acceptable return codes or a single value. Default: 0.
117
117
118
-
#####`timeout`
118
+
#####`timeout`
119
119
Sets the maximum time in seconds that the command should take. Valid options: Number or string representation of a number. Default: 300.
120
120
121
-
#####`tries`
121
+
#####`tries`
122
122
Determines the number of times execution of the command should be attempted. Valid options: Number or a string representation of a number. Default: '1'.
123
123
124
-
#####`try_sleep`
124
+
#####`try_sleep`
125
125
Specifies the time to sleep in seconds between `tries`. Valid options: Number or a string representation of a number. Default: Undefined.
126
126
127
-
#####`unless`
127
+
#####`unless`
128
128
Runs the `exec`, unless the command returns 0. Valid options: String. Default: Undefined.
129
129
130
-
##Limitations
130
+
##Limitations
131
131
132
-
* Only supported on Windows Server 2003 and above, and Windows 7 and above.
132
+
* Only supported on Windows Server 2008 and above, and Windows 7 and above.
133
133
134
-
##Development
134
+
* Only supported on Powershell 2.0 and above.
135
+
136
+
## Development
135
137
136
138
Puppet Inc modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can’t access the huge number of platforms and myriad hardware, software, and deployment configurations that Puppet is intended to serve. We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. For more information, see our [module contribution guide.](https://docs.puppet.com/forge/contributing.html)
0 commit comments