public
Created

managing an IIS AppPool from Ruby

  • Download Gist
app_pool.rb
Ruby
1 2 3 4 5 6 7 8 9 10
require 'win32ole'
 
# Connect to the WMI WebAdministration namespace.
web_admin = WIN32OLE.connect("winmgmts:root\\WebAdministration")
app_pool = web_admin.get("ApplicationPool.Name='DefaultAppPool'")
 
app_pool.stop
app_pool.start
 
app_pool.recycle
iis_tools.rb
Ruby
1 2 3 4 5 6 7 8
require 'win32/registry'
 
keyname = "SOFTWARE\\Microsoft\\InetStp\\Components"
registry = Win32::Registry::HKEY_LOCAL_MACHINE.open(keyname)
 
tools_installed = registry["ManagementScriptingTools"] == 1
 
puts "IIS Management Scripts and Tools installed? #{tools_installed}"

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.