Let's start with an analysis of the run method of the module to understand how it works:
def run raise "Powershell not available" if ! have_powershell? script = make_subs(read_script(datastore['SCRIPT']), process_subs(datastore['SUBSTITUTIONS'])) print_status psh_exec(script) print_good 'Finished!'end
- First, it verifies that the requirements are met, in this case whether PowerShell is available; if not it raises an exception:
raise "Powershell not available" if ! have_powershell?
- Next, it reads and preprocesses the PowerShell script supplied and saves the result in a variable named script:
script = make_subs(read_script(datastore['SCRIPT']), process_subs(datastore['SUBSTITUTIONS']))
- Finally, it calls the psh_exec method ...