![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | WMI Timeout with .NET question Does anyone have an example of using .NET classes to issue a remote WMI call with a timeout value specified? The cmdlet will hang in certain circumstances indefinitely... which bites if you are 5 into a list of 100 computers I haven't discovered a way to programaticallymonitor/trap/break out of a hung WMI, so I'm hoping using the .NET class will allow me to circumvent this problem. -- gaurhoth http://gaurhothw.spaces.live.com/ |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: WMI Timeout with .NET question I should have added, that it's not a firewall type issue causing the hang --- as it's only certain WMI calls. For instance... to the SAME computer, I can do a gwmi -co $cn -list and even a gwmi -co $cn -class win32_computersystem but if I do a gwmi -co $cn -class win32_service -filter "NAME like 'Symantec%AntiVirus'" it hangs indefinitely (well I killed it at the 2 hour mark... I figured it was safe to give up). So in the long run, my ultimate goal is to allow the script to continue and not have this 'hang' compromise the entire script's ability to complete. -- gaurhoth http://gaurhothw.spaces.live.com/ "Gaurhoth" <gaurhoth@live.com> wrote in message news:e8T4kp0LHHA.4376@TK2MSFTNGP03.phx.gbl... > Does anyone have an example of using .NET classes to issue a remote WMI > call with a timeout value specified? The cmdlet will hang in certain > circumstances indefinitely... which bites if you are 5 into a list of 100 > computers I haven't discovered a way to programatically> monitor/trap/break out of a hung WMI, so I'm hoping using the .NET class > will allow me to circumvent this problem. > > > -- > > gaurhoth > http://gaurhothw.spaces.live.com/ > > |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: WMI Timeout with .NET question you can give the timeout in the options in ticks (before setting class and computer): e.g. to make it 1,5 seconds : $wmi = [wmi]'' PS H:\> $wmi.psbase.Options.timeout = 15000000 PS H:\> "$($wmi.psbase.Options.timeout)" 00:00:01.5000000 Greetings /\/\o\/\/ "Gaurhoth" wrote: > I should have added, that it's not a firewall type issue causing the > hang --- as it's only certain WMI calls. For instance... to the SAME > computer, I can do a > > gwmi -co $cn -list > and even a > gwmi -co $cn -class win32_computersystem > > but if I do a > > gwmi -co $cn -class win32_service -filter "NAME like 'Symantec%AntiVirus'" > > it hangs indefinitely (well I killed it at the 2 hour mark... I figured it > was safe to give up). > > So in the long run, my ultimate goal is to allow the script to continue and > not have this 'hang' compromise the entire script's ability to complete. > > -- > > gaurhoth > http://gaurhothw.spaces.live.com/ > > > "Gaurhoth" <gaurhoth@live.com> wrote in message > news:e8T4kp0LHHA.4376@TK2MSFTNGP03.phx.gbl... > > Does anyone have an example of using .NET classes to issue a remote WMI > > call with a timeout value specified? The cmdlet will hang in certain > > circumstances indefinitely... which bites if you are 5 into a list of 100 > > computers I haven't discovered a way to programatically> > monitor/trap/break out of a hung WMI, so I'm hoping using the .NET class > > will allow me to circumvent this problem. > > > > > > -- > > > > gaurhoth > > http://gaurhothw.spaces.live.com/ > > > > > > |
My System Specs![]() |
| | #4 (permalink) |
| Guest | Re: WMI Timeout with .NET question Using /\/\o\/\/'s example, I am able to set the timeout with below code: PS ps:\> $wmi = [wmi]"" PS ps:\> $wmi.psbase.options.timeout = 15000000 PS ps:\> $wmi.path = "\\computer1\root\cimv2:Win32_Service.Name='Symantec AntiVirus'" but it does the same thing as get-wmiobject ... hangs. Grr! Part of this scripts purpose is to find unhappy machines... but the ones that are most unhappy are stopping the script cold. Oh well... if anyone has any other ideas on how a script can recognize and recover from these hangs, I'm all ears. -- gaurhoth http://gaurhothw.spaces.live.com/ "/\/\o\/\/ [MVP]" <oMVP@discussions.microsoft.com> wrote in message news:8C75E2A3-9BDB-41AC-B721-3D1AC98C4852@microsoft.com... > you can give the timeout in the options in ticks (before setting class and > computer): > > e.g. to make it 1,5 seconds : > > $wmi = [wmi]'' > PS H:\> $wmi.psbase.Options.timeout = 15000000 > PS H:\> "$($wmi.psbase.Options.timeout)" > 00:00:01.5000000 > > Greetings /\/\o\/\/ > > > "Gaurhoth" wrote: > >> I should have added, that it's not a firewall type issue causing the >> hang --- as it's only certain WMI calls. For instance... to the SAME >> computer, I can do a >> >> gwmi -co $cn -list >> and even a >> gwmi -co $cn -class win32_computersystem >> >> but if I do a >> >> gwmi -co $cn -class win32_service -filter "NAME like >> 'Symantec%AntiVirus'" >> >> it hangs indefinitely (well I killed it at the 2 hour mark... I figured >> it >> was safe to give up). >> >> So in the long run, my ultimate goal is to allow the script to continue >> and >> not have this 'hang' compromise the entire script's ability to complete. >> >> -- >> >> gaurhoth >> http://gaurhothw.spaces.live.com/ >> >> >> "Gaurhoth" <gaurhoth@live.com> wrote in message >> news:e8T4kp0LHHA.4376@TK2MSFTNGP03.phx.gbl... >> > Does anyone have an example of using .NET classes to issue a remote WMI >> > call with a timeout value specified? The cmdlet will hang in certain >> > circumstances indefinitely... which bites if you are 5 into a list of >> > 100 >> > computers I haven't discovered a way to programatically>> > monitor/trap/break out of a hung WMI, so I'm hoping using the .NET >> > class >> > will allow me to circumvent this problem. >> > >> > >> > -- >> > >> > gaurhoth >> > http://gaurhothw.spaces.live.com/ >> > >> > >> >> |
My System Specs![]() |
| | #5 (permalink) |
| Guest | Re: WMI Timeout with .NET question if its only on a couple of machines try deleting the repository directory. could be WMI is corrupted (you can test this first in computer management on the affected computer (Service and applications -> WMI control properties)) if this not works WMI is corrupt, delete the repository directory h.t.h. Greetings /\/\o\/\/ "Gaurhoth" <gaurhoth@live.com> wrote in message news:eMX$ez1LHHA.5000@TK2MSFTNGP03.phx.gbl... > Using /\/\o\/\/'s example, I am able to set the timeout with below code: > > PS ps:\> $wmi = [wmi]"" > PS ps:\> $wmi.psbase.options.timeout = 15000000 > PS ps:\> $wmi.path = "\\computer1\root\cimv2:Win32_Service.Name='Symantec > AntiVirus'" > > but it does the same thing as get-wmiobject ... hangs. Grr! Part of this > scripts purpose is to find unhappy machines... but the ones that are most > unhappy are stopping the script cold. > > Oh well... if anyone has any other ideas on how a script can recognize and > recover from these hangs, I'm all ears. > -- > > gaurhoth > http://gaurhothw.spaces.live.com/ > > > "/\/\o\/\/ [MVP]" <oMVP@discussions.microsoft.com> wrote in message > news:8C75E2A3-9BDB-41AC-B721-3D1AC98C4852@microsoft.com... >> you can give the timeout in the options in ticks (before setting class >> and >> computer): >> >> e.g. to make it 1,5 seconds : >> >> $wmi = [wmi]'' >> PS H:\> $wmi.psbase.Options.timeout = 15000000 >> PS H:\> "$($wmi.psbase.Options.timeout)" >> 00:00:01.5000000 >> >> Greetings /\/\o\/\/ >> >> >> "Gaurhoth" wrote: >> >>> I should have added, that it's not a firewall type issue causing the >>> hang --- as it's only certain WMI calls. For instance... to the SAME >>> computer, I can do a >>> >>> gwmi -co $cn -list >>> and even a >>> gwmi -co $cn -class win32_computersystem >>> >>> but if I do a >>> >>> gwmi -co $cn -class win32_service -filter "NAME like >>> 'Symantec%AntiVirus'" >>> >>> it hangs indefinitely (well I killed it at the 2 hour mark... I figured >>> it >>> was safe to give up). >>> >>> So in the long run, my ultimate goal is to allow the script to continue >>> and >>> not have this 'hang' compromise the entire script's ability to complete. >>> >>> -- >>> >>> gaurhoth >>> http://gaurhothw.spaces.live.com/ >>> >>> >>> "Gaurhoth" <gaurhoth@live.com> wrote in message >>> news:e8T4kp0LHHA.4376@TK2MSFTNGP03.phx.gbl... >>> > Does anyone have an example of using .NET classes to issue a remote >>> > WMI >>> > call with a timeout value specified? The cmdlet will hang in certain >>> > circumstances indefinitely... which bites if you are 5 into a list of >>> > 100 >>> > computers I haven't discovered a way to programatically>>> > monitor/trap/break out of a hung WMI, so I'm hoping using the .NET >>> > class >>> > will allow me to circumvent this problem. >>> > >>> > >>> > -- >>> > >>> > gaurhoth >>> > http://gaurhothw.spaces.live.com/ >>> > >>> > >>> >>> > |
My System Specs![]() |
| | #6 (permalink) |
| Guest | Re: WMI Timeout with .NET question Hi there! I have the same problem with some of the machines I'm trying to connect to. Now I think I finally found a way to set a timeout! Here is what I did: PS H:\> $options.set_Username("user") PS H:\> $options.set_Password("password") PS H:\> $timeout = new-timespan -seconds 5 PS H:\> $options.set_timeout($timeout) # this didn't help with the wmi queries at all.... PS H:\> $Scope = new-object System.Management.ManagementScope "\\someserver\root\cimv2", $options PS H:\> $Scope.Connect() PS H:\> PS H:\> $query = new-object System.Management.ObjectQuery "SELECT * FROM Win32_OperatingSystem" PS H:\> $searcher = new-object System.Management.ManagementObjectSearcher $scope,$query PS H:\> PS H:\> $SearchOption = $searcher.get_options() ## $SearchOption returns something like this: ReturnImmediately : True BlockSize : 1 Rewindable : True UseAmendedQualifiers : False EnsureLocatable : False PrototypeOnly : False DirectRead : False EnumerateDeep : False Context : {} Timeout : 10675199.02:48:05.4775807 PS H:\> $SearchOption.set_timeout($timeout) ## set new timeout after setting the timeout: ReturnImmediately : True BlockSize : 1 Rewindable : True UseAmendedQualifiers : False EnsureLocatable : False PrototypeOnly : False DirectRead : False EnumerateDeep : False Context : {} Timeout : 00:00:05 PS H:\> $searcher.set_options($SearchOption) PS H:\> PS H:\> $searcher.get() An error occurred while enumerating through a collection: Timed out . At line:1 char:14 + $searcher.get( <<<< ) PS H:\> -> ![]() Hope this helps. If someone refines the code please post it ![]() wbr Roman "Gaurhoth" wrote: > Using /\/\o\/\/'s example, I am able to set the timeout with below code: > > PS ps:\> $wmi = [wmi]"" > PS ps:\> $wmi.psbase.options.timeout = 15000000 > PS ps:\> $wmi.path = "\\computer1\root\cimv2:Win32_Service.Name='Symantec > AntiVirus'" > > but it does the same thing as get-wmiobject ... hangs. Grr! Part of this > scripts purpose is to find unhappy machines... but the ones that are most > unhappy are stopping the script cold. > > Oh well... if anyone has any other ideas on how a script can recognize and > recover from these hangs, I'm all ears. > -- > > gaurhoth > http://gaurhothw.spaces.live.com/ > > > "/\/\o\/\/ [MVP]" <oMVP@discussions.microsoft.com> wrote in message > news:8C75E2A3-9BDB-41AC-B721-3D1AC98C4852@microsoft.com... > > you can give the timeout in the options in ticks (before setting class and > > computer): > > > > e.g. to make it 1,5 seconds : > > > > $wmi = [wmi]'' > > PS H:\> $wmi.psbase.Options.timeout = 15000000 > > PS H:\> "$($wmi.psbase.Options.timeout)" > > 00:00:01.5000000 > > > > Greetings /\/\o\/\/ > > > > > > "Gaurhoth" wrote: > > > >> I should have added, that it's not a firewall type issue causing the > >> hang --- as it's only certain WMI calls. For instance... to the SAME > >> computer, I can do a > >> > >> gwmi -co $cn -list > >> and even a > >> gwmi -co $cn -class win32_computersystem > >> > >> but if I do a > >> > >> gwmi -co $cn -class win32_service -filter "NAME like > >> 'Symantec%AntiVirus'" > >> > >> it hangs indefinitely (well I killed it at the 2 hour mark... I figured > >> it > >> was safe to give up). > >> > >> So in the long run, my ultimate goal is to allow the script to continue > >> and > >> not have this 'hang' compromise the entire script's ability to complete. > >> > >> -- > >> > >> gaurhoth > >> http://gaurhothw.spaces.live.com/ > >> > >> > >> "Gaurhoth" <gaurhoth@live.com> wrote in message > >> news:e8T4kp0LHHA.4376@TK2MSFTNGP03.phx.gbl... > >> > Does anyone have an example of using .NET classes to issue a remote WMI > >> > call with a timeout value specified? The cmdlet will hang in certain > >> > circumstances indefinitely... which bites if you are 5 into a list of > >> > 100 > >> > computers I haven't discovered a way to programatically> >> > monitor/trap/break out of a hung WMI, so I'm hoping using the .NET > >> > class > >> > will allow me to circumvent this problem. > >> > > >> > > >> > -- > >> > > >> > gaurhoth > >> > http://gaurhothw.spaces.live.com/ > >> > > >> > > >> > >> > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| server timeout | beastymantis | Live Folder Share | 1 | 06-18-2008 04:12 PM |
| Command Timeout | rob schieber | .NET General | 1 | 05-05-2008 04:43 PM |
| timeout functionality | Frank | PowerShell | 7 | 07-31-2007 04:52 PM |
| Anyway to timeout a command | Frank | PowerShell | 1 | 04-17-2007 03:20 AM |
| pipeline timeout | William Stacey [C# MVP] | PowerShell | 0 | 04-09-2007 03:26 PM |