Checking WMI connectivity via cmd-line RRS feed

  • Question

  • Hi, 

    I'm trying to test a huge list of severs for  their WMI connectivity, I know of the GUI program wbemtest.exe but there is doing it one by one. Pls help to advice or recommend any cmd which i can use to write a simple .bat file to do the test.

    Thanks in advance.

    Soong WC

    Forum admin: sorry if i posted in the wrong place, and kind advice on where i should post for WMI question as I had search the forum and couldn't find a thread or sub forum to post question WMI.

    Wednesday, December 10, 2014 7:49 AM


All replies

  • Wednesday, December 10, 2014 8:13 AM
  • What I did in one of my scripts was to test port 135 and 445 to verify WMI connection to the server, might not be bulletproof but it worked. Sample code below:

    $TargetServers = Get-Content "[PATH TO TXT FILE WITH SERVERNAMES]"
    $logfile = New-Item "[PATH TO OUTPUTFILE]" -ItemType file

    foreach ($server in $TargetServers){
    #Test server connection port 135 and 445
    echo "Testing connection to $server on port 135 and 445" | Out-File -FilePath $logfile -Append
    $ip1=test-connection $server -count 1 -timetolive 5; $ip2=$ip1.ipv4address
    $ConnTest135 = New-Object Net.Sockets.TcpClient("$ips", 135)
    $ConnTest445 = New-Object net.sockets.TcpClient("$ips", 445)

    If ($ConnTest135.Connected -and $ConnTest445.Connected){
    echo "Connection to $server successful" | Out-File -FilePath $logfile -Append}

    / Niklas

    Wednesday, December 10, 2014 9:49 AM
    • Marked as answer by Bill_Stewart Monday, February 2, 2015 8:01 PM
    Wednesday, December 10, 2014 11:30 AM
  • hi guys, thanks for the reply, I'll go read up on informs test it out:) regards soong
    Friday, December 12, 2014 12:45 AM