Skip to content

Instantly share code, notes, and snippets.

@glennsarti
Created October 19, 2016 20:53
Show Gist options
  • Save glennsarti/0a816eccf96ac9f52424bc267f56d851 to your computer and use it in GitHub Desktop.
Save glennsarti/0a816eccf96ac9f52424bc267f56d851 to your computer and use it in GitHub Desktop.
Example WMI Chassis Query
Facter.add('windows_chassistype') do
confine :osfamily => :windows
setcode do
begin
require 'win32ole' if Puppet.features.microsoft_windows?
wmi = WIN32OLE.connect("winmgmts://./root/cimv2")
enclosure = wmi.ExecQuery("SELECT * FROM Win32_SystemEnclosure").each.first
enclosure.ChassisTypes # == [10] for a lpatop
rescue
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment