Skip to content
This repository has been archived by the owner on Feb 18, 2022. It is now read-only.

Update dism.rb #38

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/puppet/provider/dism/dism.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def self.prefetch(resources)
end

def self.instances
features = dism '/online', '/Get-Features'
features = dism '/english', '/online', '/Get-Features'
features = features.scan(/^Feature Name : ([\w-]+)\nState : (\w+)/)
features.collect do |f|
new(:name => f[0], :state => f[1])
Expand All @@ -35,14 +35,14 @@ def flush
end

def create
cmd = [command(:dism), '/online', '/Enable-Feature']
cmd = [command(:dism), '/english', '/online', '/Enable-Feature']
if resource[:all]
cmd << '/All'
end
cmd << "/FeatureName:#{resource[:name]}"
cmd << '/Quiet'
if resource[:source]
cmd << "/Source:'#{resource[:source]}'"
cmd << "/Source:\"#{resource[:source]}\""
end
if resource[:answer]
cmd << "/Apply-Unattend:#{resource[:answer]}"
Expand All @@ -58,15 +58,15 @@ def create
end

def destroy
cmd = ['/online', '/Disable-Feature', "/FeatureName:#{resource[:name]}", '/Quiet']
cmd = ['/english', '/online', '/Disable-Feature', "/FeatureName:#{resource[:name]}", '/Quiet']
if resource[:norestart] == :true
cmd << '/NoRestart'
end
dism cmd
end

def currentstate
feature = dism(['/online', '/Get-FeatureInfo', "/FeatureName:#{resource[:name]}"])
feature = dism(['/english', '/online', '/Get-FeatureInfo', "/FeatureName:#{resource[:name]}"])
feature =~ /^State : (\w+)/
$1
end
Expand Down