I'm trying to track down an error that in my applicatio. Can anyone narrow down a cmdlet that would use this method?
Here is the full event:
Log Name: Application
Source: .NET Runtime
Date: 7/30/2014 9:22:04 AM
Event ID: 1026
Task Category: None
Level: Error
Keywords: Classic
User: N/A
Computer:
Description:
Application: MonitoringHost.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IndexOutOfRangeException
Stack:
at VMware.VimAutomation.ViCore.Impl.V1.Service.ViCoreServiceImpl.UnregisterClientService(VMware.VimAutomation.ViCore.Interop.V1.VIAutomation, System.Type, System.Object)
at VMware.VimAutomation.ViCore.Impl.V1.VimClient.Finalize()
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name=".NET Runtime" />
<EventID Qualifiers="0">1026</EventID>
<Level>2</Level>
<Task>0</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2014-07-30T13:22:04.000000000Z" />
<EventRecordID>107253</EventRecordID>
<Channel>Application</Channel>
<Computer>RHWAPP427E.corp.ds.hfhs.org</Computer>
<Security />
</System>
<EventData>
<Data>Application: MonitoringHost.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IndexOutOfRangeException
Stack:
at VMware.VimAutomation.ViCore.Impl.V1.Service.ViCoreServiceImpl.UnregisterClientService(VMware.VimAutomation.ViCore.Interop.V1.VIAutomation, System.Type, System.Object)
at VMware.VimAutomation.ViCore.Impl.V1.VimClient.Finalize()
</Data>
</EventData>
</Event>
Do you have a SCOM agent running on that box ?
That could explain the monitoringhost.exe.
From the exception, it looks like the Disconnect-VIServer might be causing this.
Can you place that, if you have it in a script, in a Try-Catch construct ?
That would allow you to look at the exception details in $error[0].
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks for the quick response LucD...
Yes, there is a SCOM agent running on there, I have several PowerCLI scripts running inside an MP.
Most of the scripts do use Disconnect-VIServer, but they are not using any Try-Catch handling.
I'll start error handling that cmdlet and see if I can avoid this error.
Thanks!
Each script is spinning up 3 threads when they are scheduled to run, 1 for each vCenter server.
I'm getting this error frequently: You have modified the global:DefaultVIServer and global:DefaultVIServers system variables. This is not allowed. Please reset them to $null and reconnect to the vSphere server.
...do I need to add the -NotDefault option to Connect-VIServer?
Thanks!
You better pass along the session token to each thread.
Clinton has a great post on this, see Multithreading PowerCLI
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Is this needed when it spins up a new shell for each vCenter server?
No, not when you start a new PowerShell.exe each time.
Are these started by the SCOM MP ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes, they all run in SCOM. I'll post the resolution when I find it.
Did you already try with the NotDefault switch ? Any improvement.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I have implemented -NotDefault with all of my connections now, but I'm not seeing any change.
I've updated a few scripts to use Try/Catch on each cmd, I'll update them all asap...
I'm seeing errors when trying to load the Snap-In:
A requested PowerCLI component was not found on the local system: VMware.VimAutomation.ViCore.Cmdlets
At line:28 char:18
+ Try {Add-PSSnapin <<<< VMware.VimAutomation.Core}
This results in the next error, which makes sense. So it seems to be having problems adding the snap-in in multiple scripts simultaneously.
The term 'Connect-VIServer' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:31 char:36
+ Try {$connection = Connect-VIServer <<<< -Server $vCenterServerName -Force:$true -NotDefault}
-NotDefault did actually clear up these errors when disconnecting:
You have modified the global:DefaultVIServer and global:DefaultVIServers system variables. This is not allowed. Please reset them to $null and reconnect to the vSphere server.
And did you get rid of the Add-PSSnapin errors ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
No, adding the snap-in does error from time to time. There is no correlating error/warning in the System or Application log either =/
A requested PowerCLI component was not found on the local system: VMware.VimAutomation.ViCore.Cmdlets
Type:System.ArgumentOutOfRangeException
At line:66 char:18
+ Try {Add-PSSnapin <<<< VMware.VimAutomation.Core}
Can you try like this
if(!(Get-PSSnapin -Name VMware.VimAutomation.Core -ErrorAction SilentlyContinue)){
Add-PSSnapin -Name VMware.VimAutomation.Core
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Well after the Add-PSSnapin error the same script fails on Connect-VIServer because it's not a recognized CmdLet. So I don't think the snap-in was already added.
I suppose I can try a Do/While loop to retry on error after sleeping for a few seconds.
Hello,
Were you able to solve this issue?
I have the exact same problem. My SCOM server is monitoring my VMware env using the Community MP and ever since I've imported it I see this error reported.