Powershell and WMI Queries

  • Nicholas Cain

    SSC-Dedicated

    Points: 33009

    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

  • Jeffrey Williams 3188

    SSC Guru

    Points: 88150

    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.

    [font="Verdana"]Jeffrey Williams
    Problems are opportunities brilliantly disguised as insurmountable obstacles.

    How to post questions to get better answers faster[/url]
    Managing Transaction Logs[/url]
    [/font]

  • Nicholas Cain

    SSC-Dedicated

    Points: 33009

    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 3 (of 3 total)

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