Land #7178, Add a method to check the Powershell version
commit
6386d9daca
|
@ -30,6 +30,31 @@ module Powershell
|
|||
return false
|
||||
end
|
||||
|
||||
#
|
||||
# Returns the Powershell version
|
||||
#
|
||||
def get_powershell_version
|
||||
return nil unless have_powershell?
|
||||
|
||||
process, pid, c = execute_script('$PSVersionTable.PSVersion')
|
||||
|
||||
o = ''
|
||||
|
||||
while (d = process.channel.read)
|
||||
if d == ""
|
||||
if (Time.now.to_i - start < time_out) && (o == '')
|
||||
sleep 0.1
|
||||
else
|
||||
break
|
||||
end
|
||||
else
|
||||
o << d
|
||||
end
|
||||
end
|
||||
|
||||
o.scan(/[\d \-]+/).last.split[0,2] * '.'
|
||||
end
|
||||
|
||||
#
|
||||
# Get/compare list of current PS processes - nested execution can spawn many children
|
||||
# doing checks before and after execution allows us to kill more children...
|
||||
|
|
Loading…
Reference in New Issue