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

Version Path
octopus-serverspec-extensions-0.18.1 lib/octopus_serverspec_extensions/type/windows_scheduled_task.rb
octopus-serverspec-extensions-0.18.0 lib/octopus_serverspec_extensions/type/windows_scheduled_task.rb
octopus-serverspec-extensions-0.17.3 lib/octopus_serverspec_extensions/type/windows_scheduled_task.rb
octopus-serverspec-extensions-0.17.2 lib/octopus_serverspec_extensions/type/windows_scheduled_task.rb
octopus-serverspec-extensions-0.17.1 lib/octopus_serverspec_extensions/type/windows_scheduled_task.rb
octopus-serverspec-extensions-0.17.0 lib/octopus_serverspec_extensions/type/windows_scheduled_task.rb
octopus-serverspec-extensions-0.15.5 lib/octopus_serverspec_extensions/type/windows_scheduled_task.rb
octopus-serverspec-extensions-0.15.4 lib/octopus_serverspec_extensions/type/windows_scheduled_task.rb
octopus-serverspec-extensions-0.15.3 lib/octopus_serverspec_extensions/type/windows_scheduled_task.rb
octopus-serverspec-extensions-0.15.2 lib/octopus_serverspec_extensions/type/windows_scheduled_task.rb
octopus-serverspec-extensions-0.15.1 lib/octopus_serverspec_extensions/type/windows_scheduled_task.rb
octopus-serverspec-extensions-0.15.0 lib/octopus_serverspec_extensions/type/windows_scheduled_task.rb
octopus-serverspec-extensions-0.13.6 lib/octopus_serverspec_extensions/type/windows_scheduled_task.rb
octopus-serverspec-extensions-0.13.5 lib/octopus_serverspec_extensions/type/windows_scheduled_task.rb
octopus-serverspec-extensions-0.13.4 lib/octopus_serverspec_extensions/type/windows_scheduled_task.rb
octopus-serverspec-extensions-0.13.3 lib/octopus_serverspec_extensions/type/windows_scheduled_task.rb
octopus-serverspec-extensions-0.13.2 lib/octopus_serverspec_extensions/type/windows_scheduled_task.rb
octopus-serverspec-extensions-0.13.1 lib/octopus_serverspec_extensions/type/windows_scheduled_task.rb
octopus-serverspec-extensions-0.13.0 lib/octopus_serverspec_extensions/type/windows_scheduled_task.rb
octopus-serverspec-extensions-0.12.2 lib/octopus_serverspec_extensions/type/windows_scheduled_task.rb