Powershell crashes with Microsoft.Update.Searcher

Hi,

This causes my powershell window to crash often. Any clue ?

$windowsUpdate = New-object -com Microsoft.Update.Searcher
$totalUpdates = $windowsUpdate.GetTotalHistoryCount()
[array]$allUpdates = $windowsUpdate.QueryHistory(0,$totalUpdates) | Where-Object {($_.ResultCode -eq 2)-and ($_.HResult -eq 0) }
$allUpdates


July 24th, 2015 10:28am

You need to repair your computer.  This is not the correct forum for help with this.

Free Windows Admin Tool Kit Click here and download it now
July 24th, 2015 10:41am

This happens across servers both on windows server 2K8R2 and 2012 R2 besides my computer. This is from eventviewer log :

Faulting application name: powershell.exe, version: 6.3.9600.16406, time stamp: 0x5244e9dc
Faulting module name: System.Management.Automation.ni.dll, version: 6.3.9600.16406, time stamp: 0x5244a9b0
Exception code: 0x80131623
Fault offset: 0x000000000127c87f
Faulting process id: 0x15d4
Faulting application start time: 0x01d0c61beb0aa6d1
Faulting application path: C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe
Faulting module path: C:\windows\assembly\NativeImages_v4.0.30319_64\System.Manaa57fc8cc#\b90384b5952a475147d9c9a2cd1e9c3d\System.Management.Automation.ni.dll
Report Id: 2c45bc35-320f-11e5-bc14-a0b3cc21fbd9

July 24th, 2015 10:53am

Not a scripting issue.  You need to fix your system.
Free Windows Admin Tool Kit Click here and download it now
July 24th, 2015 11:02am

Hey jrv

did you even try this before posting ?  I think you need to run this to appreciate what my concerns are. These lines are part of a diagnostics tool which outputs result in an xml file. Eveything is perfect till $allUpdates, then when i process the contents of the variable , it crashes.

It's kind of random in nature.Sometimes it runs perfectly and other times it does not.

I think you need to run these to see what i mean . Please try it for a couple of times before posting next time.

Thanks  for your quick response.

July 24th, 2015 1:23pm

Hey jrv

did you even try this before posting ?  I think you need to run this to appreciate what my concerns are. These lines are part of a diagnostics tool which outputs result in an xml file. Eveything is perfect till $allUpdates, then when i process the contents of the variable , it crashes.

It's kind of random in nature.Sometimes it runs perfectly and other times it does not.

I think you need to run these to see what i mean . Please try it for a couple of times before posting next time.

Thanks  for your quick response.

Yes I have used the update searcher class for years.

Free Windows Admin Tool Kit Click here and download it now
July 24th, 2015 1:51pm

Just to satisfy you I ran your exact code with copy/paste and it runs without issue.

You need to fix your systems.

July 24th, 2015 1:53pm

This fails for me as well. I tried on multiple versions and operating systems and it crashes each time for me.

Win7:

PS C:\> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      4.0
WSManStackVersion              3.0
SerializationVersion           1.1.0.1
CLRVersion                     4.0.30319.34209
BuildVersion                   6.3.9600.16406
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion      2.2

WS2012:

PS C:\> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      3.0
WSManStackVersion              3.0
SerializationVersion           1.1.0.1
CLRVersion                     4.0.30319.34209
BuildVersion                   6.2.9200.17065
PSCompatibleVersions           {1.0, 2.0, 3.0}
PSRemotingProtocolVersion      2.2

WS2012R2:

PS C:\> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      4.0
WSManStackVersion              3.0
SerializationVersion           1.1.0.1
CLRVersion                     4.0.30319.34209
BuildVersion                   6.3.9600.17400
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion      2.2

jrv - Are you on Win8.1? I don't have any handy to test

Free Windows Admin Tool Kit Click here and download it now
July 24th, 2015 2:28pm

I am on 8.1/7/2008R2

I will test on 2012R2 later buit all work and all versions of Ps 3,4,5

July 24th, 2015 3:07pm

Check up your Event Logs. There shout be an error event in your logs (Logname: Application; ProviderName: .NET Runtime and/or Microsoft-Windows-Powershell). It should give you more information about the cause of your crashes.

Maybe, you could post the error messages.

wizend

Free Windows Admin Tool Kit Click here and download it now
July 24th, 2015 3:55pm

Interesting:

Application: powershell.exe
Framework Version: v4.0.30319
Description: The application requested process termination through System.Environment.FailFast(string message).
Message: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

July 24th, 2015 6:22pm

If you look up the error code or the "FailFast()" bit you will see that it is Net Framework that is shutting down.  PowerShell is build on NetF and is just being dragged along for the ride.

I suspect a missing patch or a new hotfix that has gone awry.

Free Windows Admin Tool Kit Click here and download it now
July 24th, 2015 7:06pm

Windows 2012R2 - no errors.  It is actually a new and almost pristeen copy I built last week and set up as a DC  It just works like anything

July 24th, 2015 7:23pm

Do the failing 2012 servers have SharePoint installed?  Do they have IIS
Free Windows Admin Tool Kit Click here and download it now
July 24th, 2015 8:40pm

This has failed on Win7,2008 R2,2012 and 2012 R2. I have not tried on Win8 versions. 

and on server versions i have IIS installed. 

July 25th, 2015 12:22am

This has failed on Win7,2008 R2,2012 and 2012 R2. I have not tried on Win8 versions. 

and on server versions i have IIS installed. 

I have IIS on Win 8.1, WS2008R2.  I do not have it on WS2012R2.

I see there are issues with SharePoint with  that exception.  I cannot reproduce the error on any platform so far.

Start from a fresh boot to see if it always happens or only after the system has been running.

Free Windows Admin Tool Kit Click here and download it now
July 25th, 2015 12:25am

Exactly to your thinking, I tried with a reboot to see if it occurs and it did occur. The behavior is random; sometimes it runs and other times it keeps on failing. Unreliable is all i can say about Microsoft.Update.Searcher class.

Can i get update history with some other means ? 

July 25th, 2015 12:43am

The problem is not the update searcher it is the system.  The WUS has been used for years with no issue.

As I noted. I cannot reproduce your issue.  You should contact MS support for assistance as it is likely due to a configuration that is unique to your systems.  We cannot fix this in this forum.

Free Windows Admin Tool Kit Click here and download it now
July 25th, 2015 12:48am

It is not unique to my system. It's happening across platforms. Even though WUS has been used for years and with no issue, does not guarantee it would be issue less in future. I definitely need to contact MS support for assistance. In the meantime. if someone find something please update it .

thanks jrv .Appreciate your replies.

July 25th, 2015 1:45am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics