@@ -56,6 +56,10 @@ def user
5656 account
5757 end
5858
59+ def group
60+ task . group_information
61+ end
62+
5963 def trigger
6064 @triggers ||= task . triggers . compact # remove nils for unsupported trigger types
6165 end
@@ -72,6 +76,14 @@ def user_insync?(current, should)
7276 Puppet ::Util ::Windows ::SID . name_to_sid ( current ) == Puppet ::Util ::Windows ::SID . name_to_sid ( should [ 0 ] )
7377 end
7478
79+ def group_insync? ( current , should )
80+ return false unless current
81+
82+ # By comparing account SIDs we don't have to worry about case
83+ # sensitivity, or canonicalization of the account name.
84+ Puppet ::Util ::Windows ::SID . name_to_sid ( current ) == Puppet ::Util ::Windows ::SID . name_to_sid ( should [ 0 ] )
85+ end
86+
7587 def trigger_insync? ( current , should )
7688 should = [ should ] unless should . is_a? ( Array )
7789 current = [ current ] unless current . is_a? ( Array )
@@ -153,12 +165,18 @@ def user=(value)
153165 end
154166 end
155167
168+ def group = ( value )
169+ raise ( "Invalid group: #{ value } " ) unless Puppet ::Util ::Windows ::SID . name_to_sid ( value )
170+
171+ task . set_group_information ( value )
172+ end
173+
156174 def create
157175 @triggers = nil
158176 @task = PuppetX ::PuppetLabs ::ScheduledTask ::Task . new ( resource [ :name ] , :v1_compatibility )
159177 self . command = resource [ :command ]
160178
161- [ :arguments , :working_dir , :enabled , :trigger , :user , :description ] . each do |prop |
179+ [ :arguments , :working_dir , :enabled , :trigger , :user , :group , : description] . each do |prop |
162180 send ( "#{ prop } =" , resource [ prop ] ) if resource [ prop ]
163181 end
164182 end
@@ -177,7 +195,7 @@ def flush
177195 # this is a Windows security feature with the v1 COM APIs that prevent
178196 # arbitrary reassignment of a task scheduler command to run as SYSTEM
179197 # without the authorization to do so
180- self . user = resource [ :user ]
198+ self . user = resource [ :user ] unless resource [ :group ]
181199 task . save
182200 @task = nil
183201 end
0 commit comments