header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
WMI Connection Test
Last Post 07 Jan 2010 10:01 AM by twooly. 0 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
twoolyUser is Offline
New Member
New Member
Posts:3
Avatar

--
07 Jan 2010 10:01 AM
    VBScript user trying to learn PowerShell.  Can someone help me on how I can just test if a machine responds to a wmi connect and get the error code?

    vbscript example

    Set objLoc = WScript.CreateObject("WbemScripting.SWbemLocator")
    Set objWmi = objLoc.ConnectServer(vServerName,DEFAULT_NAMESPACE,,,,,wbemConnectFlagUseMaxWait)
    If Err.Number Then
      'wmi doesn't respond
    else
      'wmi responds
    End if

    I understand using the get-wmiobject but don't really need to see the full details, only if it connects or not.  Doing this for a monitoring type of script.

    Get-WmiObject Win32_LocalTime -computername server1 -ErrorVariable $myerror
    Trap [system.exception] {$z=$null;continue}
    write-host $myerror

    Thanks a bunch
    --Todd
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer