Class: Mixlibrary::Core::Shell::Scripts::Powershell

Inherits:
WindowsScript show all
Defined in:
lib/mixlibrary/core/shell/scripts/powershell.rb

Instance Method Summary collapse

Constructor Details

#initialize(script, validate, options, flags, architecture = nil) ⇒ Powershell

Returns a new instance of Powershell.



16
17
18
19
20
21
22
# File 'lib/mixlibrary/core/shell/scripts/powershell.rb', line 16

def initialize(script, validate, options, flags, architecture = nil)
  super(architecture)
  @originalScript=script
  @options = options
  @validate=validate
  @flagoverrides=flags
end

Instance Method Details

#orchestrateObject



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/mixlibrary/core/shell/scripts/powershell.rb', line 24

def orchestrate
  #Powershell kind of sucks with syntax checking.
  #If any part of the script syntactically fails it will exit with a clean exit code of 0
  #So this forced our hand to call powershell twice for every script call.
  #1 - Put passed in script in a function to see if any standard error is generated - 
  #only will happen if syntax is incorrect since function is never called
  #2 - Run the user script with exception wraps to guarantee some exit status
  syntax_check()
  
  myscriptstring = finalscript()
  
  return run_command(shell,flags,filename,file_extension, myscriptstring, @options, @validate)
end