Powershell and WMI Queries

  • I'm having some troubles with WMI queries.

    The queries themselves are fine my problem comes when running

    Get-WmiObject -class "Win32_Service" -computername $server -Filter "Name = '$instance'" | SELECT Name, State

    The code itself works without an issue....except in a situation where a server is hung up and will accept in a WMI query however not return any results.

    There isn't any timeout value that can be set on WMI queries (something I find most strange), is anyone aware of a way to force some kind of a timeout value in powershell so that the script will force a timeout value any server that doesn't return data in 10 seconds?



    Shamless self promotion - read my blog http://sirsql.net

  • Here are a couple of links that might lead you to a solution. If so, let us know how it works out:

    http://windowsitpro.com/articles/print.cfm?articleid=101451

    http://blog.usepowershell.com/page/2/

    I have the same issue and will be looking into this further myself.

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

  • I've looked through those links, they were part of the heck knows how many pages I trawled through trying to find an answer. There were a couple of things that indicated that they may do the job, however my serious programming limitations along with there not being the full code to make it happen prevented me from doing anything with it.



    Shamless self promotion - read my blog http://sirsql.net

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply