44 confine :operatingsystem => :windows
55 confine :feature => :pwshlib
66
7- def self . powershell_path
8- begin
9- require 'ruby-pwsh'
10- Pwsh ::Manager . powershell_path
11- rescue
12- nil
13- end
14- end
15- commands :powershell => self . powershell_path
16-
177 desc <<-EOT
188 Executes Powershell commands. One of the `onlyif`, `unless`, or `creates`
199 parameters should be specified to ensure the command is idempotent.
@@ -57,7 +47,7 @@ def self.upgrade_message
5747
5848 def ps_manager
5949 debug_output = Puppet ::Util ::Log . level == :debug
60- Pwsh ::Manager . instance ( command ( :powershell ) , Pwsh ::Manager . powershell_args , debug : debug_output )
50+ Pwsh ::Manager . instance ( Pwsh :: Manager . powershell_path , Pwsh ::Manager . powershell_args , debug : debug_output )
6151 end
6252
6353 def run ( command , check = false )
@@ -72,7 +62,7 @@ def run(command, check = false)
7262 # we redirect powershell's stdin to read from the file. Current
7363 # versions of Windows use per-user temp directories with strong
7464 # permissions, but I'd rather not make (poor) assumptions.
75- return super ( "cmd.exe /c \" \" #{ native_path ( command ( :powershell ) ) } \" #{ legacy_args } -Command - < \" #{ native_path } \" \" " , check )
65+ return super ( "cmd.exe /c \" \" #{ native_path ( Pwsh :: Manager . powershell_path ) } \" #{ legacy_args } -Command - < \" #{ native_path } \" \" " , check )
7666 end
7767 else
7868 return execute_resource ( command , resource )
0 commit comments