All
i am trying to write a script for mom 2007, which will check for wmi and do an nslookup. i'm getting stuck with some of the syntax as i'm new to all this, was wondering if someone could help? Script has been split into 2 for now, 1st part is this:
Option Explicit
Dim oArgs, oShell, fso, oNetwork
Dim wmistatus
Dim objWMIservice
Dim objWMI
Set oArgs = WScript.Arguments
set oShell = CreateObject("Wscript.Shell")
Set fso = CreateObject("scripting.filesystemobject")
set oNetwork = CreateObject("Wscript.Network")
'Start of main
'Check WMI is running
wmistatus = IsWMIRunning(objWMI)
If wmistatus <> False Then
wmiMessage = "WMI is running"
Else
wmiMessage = "Cannot query WMI"
End If
'Query disk space (no point if WMI is down)
If wmistatus <> False Then
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & oNetwork.ComputerName & "\root\cimv2")
Set colItems = objWMIService.ExecQuery ("Select DeviceID, FreeSpace from Win32_LogicalDisk where DriveType = 3")
For Each objItem in colItems
'Write to return event
DiskName = objItem.DeviceID
MBFree = formatnumber((objItem.FreeSpace/1048576),2)
diskmessage = diskmessage & "Name: " & DiskName & " Free megabytes: " & MBFree & VbCrLf
Next
End If
'Check WMI
Function IsWMIRunning()
On Error Resume Next
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & oNetwork.ComputerName & "\root\cimv2")
If Err Then
IsWMIRunning = False
Else
IsWMIRunning = True
End If
End Function
i get variable undefined error - states that wmistatus is the problem. but i don't know what i'm doing wrong here - any ideas?
Thanks
i am trying to write a script for mom 2007, which will check for wmi and do an nslookup. i'm getting stuck with some of the syntax as i'm new to all this, was wondering if someone could help? Script has been split into 2 for now, 1st part is this:
Option Explicit
Dim oArgs, oShell, fso, oNetwork
Dim wmistatus
Dim objWMIservice
Dim objWMI
Set oArgs = WScript.Arguments
set oShell = CreateObject("Wscript.Shell")
Set fso = CreateObject("scripting.filesystemobject")
set oNetwork = CreateObject("Wscript.Network")
'Start of main
'Check WMI is running
wmistatus = IsWMIRunning(objWMI)
If wmistatus <> False Then
wmiMessage = "WMI is running"
Else
wmiMessage = "Cannot query WMI"
End If
'Query disk space (no point if WMI is down)
If wmistatus <> False Then
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & oNetwork.ComputerName & "\root\cimv2")
Set colItems = objWMIService.ExecQuery ("Select DeviceID, FreeSpace from Win32_LogicalDisk where DriveType = 3")
For Each objItem in colItems
'Write to return event
DiskName = objItem.DeviceID
MBFree = formatnumber((objItem.FreeSpace/1048576),2)
diskmessage = diskmessage & "Name: " & DiskName & " Free megabytes: " & MBFree & VbCrLf
Next
End If
'Check WMI
Function IsWMIRunning()
On Error Resume Next
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & oNetwork.ComputerName & "\root\cimv2")
If Err Then
IsWMIRunning = False
Else
IsWMIRunning = True
End If
End Function
i get variable undefined error - states that wmistatus is the problem. but i don't know what i'm doing wrong here - any ideas?
Thanks