|
server
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
find server info
i want a script, which will find the following information from the server
and output it in a text file..with the server name MC Server Name Support Group Installation Status IP Address M/C Serial Number Machine Type Server Type Operating System OS Patch Level Tape Drive [if any] Installed CPU Installed Memory - Memory Size Installed Internal Disk Installed External Disks Software[s] Installed try this..this will give more of querries
On Error Resume Next Const wbemFlagReturnImmediately = &h10 Const wbemFlagForwardOnly = &h20 set args = wscript.arguments strComputer = args(0) 'machine name wscript.echo "Getting information about server " & args(0) & "..." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem", "WQL", _ wbemFlagReturnImmediately + wbemFlagForwardOnly) For Each objItem In colItems WScript.Echo "Server Name: " & objItem.Name WScript.Echo "BootupState: " & objItem.BootupState WScript.Echo "CurrentTimeZone (Offset from GMT in Minutes): " & objItem.CurrentTimeZone WScript.Echo "Description: " & objItem.Description WScript.Echo "Domain: " & objItem.Domain WScript.Echo "Manufacturer: " & objItem.Manufacturer WScript.Echo "Model: " & objItem.Model WScript.Echo "NumberOfProcessors: " & objItem.NumberOfProcessors WScript.Echo "TotalPhysicalMemory: " & round(objItem.TotalPhysicalMemory/(1024*1024)) & "MB (Approx.)" WScript.Echo "Console Logged-on UserName (if any): " & objItem.UserName Next Function WMIDateStringToDate(dtmDate) WScript.Echo dtm: WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _ Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _ & " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2)) End Function Show quote "Miztiik" wrote: > i want a script, which will find the following information from the server > and output it in a text file..with the server name > > MC Server Name > Support Group > Installation Status > IP Address > M/C Serial Number > Machine Type > Server Type > Operating System > OS Patch Level > Tape Drive [if any] > Installed CPU > Installed Memory - Memory Size > Installed Internal Disk > Installed External Disks > Software[s] Installed i copied this and made it into a info.vbs
On Error Resume Next Const wbemFlagReturnImmediately = &h10 Const wbemFlagForwardOnly = &h20 set args = wscript.arguments strComputer = args(0) 'machine name wscript.echo "Getting information about server " & args(0) & "..." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem", "WQL", _ wbemFlagReturnImmediately + wbemFlagForwardOnly) For Each objItem In colItems WScript.Echo "Server Name: " & objItem.Name WScript.Echo "BootupState: " & objItem.BootupState WScript.Echo "CurrentTimeZone (Offset from GMT in Minutes): " &objItem.CurrentTimeZone WScript.Echo "Description: " & objItem.Description WScript.Echo "Domain: " & objItem.Domain WScript.Echo "Manufacturer: " & objItem.Manufacturer WScript.Echo "Model: " & objItem.Model WScript.Echo "NumberOfProcessors: " & objItem.NumberOfProcessors WScript.Echo "TotalPhysicalMemory: " & round(objItem.TotalPhysicalMemory/(1024*1024)) & "MB (Approx.)" WScript.Echo "Console Logged-on UserName (if any): " & objItem.UserName Next Function WMIDateStringToDate(dtmDate) WScript.Echo dtm: WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _ Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _ & " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2)) End Function But i dont get any reply/anything on the screen when i run it
Show quote
"Miztiik" <Mizt***@discussions.microsoft.com> wrote in message Step 1 always is to remove "On Error Resume Next". Troubleshooting is news:7B6ABE3F-2462-4931-BC9E-654B2276EFF0@microsoft.com... >i copied this and made it into a info.vbs > > On Error Resume Next > > Const wbemFlagReturnImmediately = &h10 > Const wbemFlagForwardOnly = &h20 > > set args = wscript.arguments > strComputer = args(0) 'machine name > wscript.echo "Getting information about server " & args(0) & "..." > Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") > Set colItems = objWMIService.ExecQuery("SELECT * FROM > Win32_ComputerSystem", > "WQL", _ > wbemFlagReturnImmediately + wbemFlagForwardOnly) > > For Each objItem In colItems > WScript.Echo "Server Name: " & objItem.Name > WScript.Echo "BootupState: " & objItem.BootupState > WScript.Echo "CurrentTimeZone (Offset from GMT in Minutes): " > &objItem.CurrentTimeZone > WScript.Echo "Description: " & objItem.Description > WScript.Echo "Domain: " & objItem.Domain > WScript.Echo "Manufacturer: " & objItem.Manufacturer > WScript.Echo "Model: " & objItem.Model > WScript.Echo "NumberOfProcessors: " & objItem.NumberOfProcessors > WScript.Echo "TotalPhysicalMemory: " & > round(objItem.TotalPhysicalMemory/(1024*1024)) & "MB (Approx.)" > WScript.Echo "Console Logged-on UserName (if any): " & objItem.UserName > Next > > > Function WMIDateStringToDate(dtmDate) > WScript.Echo dtm: > WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _ > Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _ > & " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & > Mid(dtmDate,13, 2)) > End Function > > But i dont get any reply/anything on the screen when i run it impossible with this. It should NEVER be used, except in special cases for one statement at a time. The script posted earlier ran fine for me. I removed "On Error Resume Next",
which allowed me to fix it. As always when you copy scripts from the newsgroups, you get line wrapping. I had to fix the lines by removing the extra carriage returns. When I ran the script without an argument (as you may have done), I got an error message about subscript out of range (this message would be hidden with "On Error Resume Next" so you would never know). The program requires an argument, which would be the NetBIOS name of the remote computer (any computer). At a command prompt, I ran the program with a command similar to: cscript info.vbs MyComputer This assumes I am in the same folder as the file info.vbs. Otherwise you must specify the full path for the file. It ran fine. You can also use the //nologo option to suppress the WSH logo information: cscript //nologo info.vbs MyServer |
|||||||||||||||||||||||