H
happy-jack
Hey I am new to ruby and I do Windows administration. I have been
playing with wmi and ruby, having a problem. This is not a problem
with th wmi part but when I use get. I am asking for a computer name
and then putting that information into the script. This does not work
[Start Code]
require 'win32ole'
puts "what is the computer name that you want to use??? "
cpuName = gets
cpuName.chomp
mgmt = WIN32OLE.connect("winmgmts:\\\\#{cpuName}")
mgmt.InstancesOf("Win32_ComputerSystem") .each{ |item| puts item.name +
"\n" + item.Manufacturer + " - " + item.Model}
mgmt.InstancesOf("Win32_SystemEnclosure").each{ |dev| puts
dev.SerialNumber}
[/End Code]
This does
[Start Code]
require 'win32ole'
cpuName = 'aname'
mgmt = WIN32OLE.connect("winmgmts:\\\\#{cpuName}")
mgmt.InstancesOf("Win32_ComputerSystem") .each{ |item| puts item.name +
"\n" + item.Manufacturer + " - " + item.Model}
mgmt.InstancesOf("Win32_SystemEnclosure").each{ |dev| puts
dev.SerialNumber}
[/End Code]
Can someone shed some light on this???
playing with wmi and ruby, having a problem. This is not a problem
with th wmi part but when I use get. I am asking for a computer name
and then putting that information into the script. This does not work
[Start Code]
require 'win32ole'
puts "what is the computer name that you want to use??? "
cpuName = gets
cpuName.chomp
mgmt = WIN32OLE.connect("winmgmts:\\\\#{cpuName}")
mgmt.InstancesOf("Win32_ComputerSystem") .each{ |item| puts item.name +
"\n" + item.Manufacturer + " - " + item.Model}
mgmt.InstancesOf("Win32_SystemEnclosure").each{ |dev| puts
dev.SerialNumber}
[/End Code]
This does
[Start Code]
require 'win32ole'
cpuName = 'aname'
mgmt = WIN32OLE.connect("winmgmts:\\\\#{cpuName}")
mgmt.InstancesOf("Win32_ComputerSystem") .each{ |item| puts item.name +
"\n" + item.Manufacturer + " - " + item.Model}
mgmt.InstancesOf("Win32_SystemEnclosure").each{ |dev| puts
dev.SerialNumber}
[/End Code]
Can someone shed some light on this???