Sha256: 9421a9cd67bf8b837f2d4b9ff6202f5b8cceae297f309b63fb9f10a6dbb9698a
Contents?: true
Size: 948 Bytes
Versions: 33
Compression:
Stored size: 948 Bytes
Contents
require 'serverspec' require 'serverspec/type/base' require 'csv' module Serverspec::Type class WindowsScheduledTask < Base attr_reader :state, :user_id, :run_level, :schedule_type, :repeat_every @exists = false def initialize(name) @name = name @runner = Specinfra::Runner stdout = `schtasks /query /tn \"#{name}\" /fo csv /v` return unless $?.success? csv = CSV.parse(stdout) @exists = true headers = csv[0] data = csv[1] @state = data[headers.index{|x|x=="Status"}] @user_id = data[headers.index{|x|x=="Run As User"}] @run_level = data[headers.index{|x|x=="Logon Mode"}] @schedule_type = data[headers.index{|x|x=="Schedule Type"}].strip @repeat_every = data[headers.index{|x|x=="Repeat: Every"}] end end def windows_scheduled_task(name) WindowsScheduledTask.new(name) end end include Serverspec::Type
Version data entries
33 entries across 33 versions & 1 rubygems