Created
October 19, 2016 20:53
-
-
Save glennsarti/0a816eccf96ac9f52424bc267f56d851 to your computer and use it in GitHub Desktop.
Example WMI Chassis Query
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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