Can't say for sure, but this part looks suspicious: System.InvalidOperationException: Operation is not valid due to the current state of the object. at Microsoft.Exchange.Data.Storage.ExchangePrincipal.get_ServerFullyQualifiedDomainName() at Microsoft.Exchange.Data.Storage.MailboxSession.Initialize(MapiStore linkedStore, LogonType logonType, ExchangePrincipal owner, DelegateLogonUser delegateUser, Object identity, OpenMailboxSessionFlags flags, GenericIdentity auxiliaryIdentity)
One notable difference between running the script yourself and running it from a scheduled task is the logon type (interactive vs. batch). From: Pfefferkorn, Pete (pfeffepe) [mailto:pfeff...@ucmail.uc.edu] Sent: Friday, March 22, 2013 12:17 PM To: MS-Exchange Admin Issues Subject: Off Topic Remote Exchange Powershell Issues. This is a little off topic but I've been banging my head against a wall trying to figure it out. We have Exchange 2010 SP2. We have a virtual machine which we setup that runs all our scripts against Exchange....provisioning, de-provisioning, reporting monitoring etc. I have dozens of scripts running on that box that run fine except for a couple that just won't run correctly in the task scheduler. If I run them adhoc on that box...not a problem. The scheduler doesn't report any errors either but I don't get results. Simple test is as follows: Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 $error.clear() get-InboxRule -mailbox xxxxxx | export-csv pete.csv get-mailbox xxxxxx | export-csv pete2.csv The get-mailbox works fine when it runs from the scheduled task. The get-inboxRule nada. Blank file. Task is set to run with highest priv. Powershell versions match. If I run this on one of our Exchange servers as a scheduled task...not a problem. I can put these couple of scripts on one of the servers but I would rather figure out the problem and get them back on our management box. In the Event Viewer I see under Windows PowerShell events 403, 400, and 600 For Engine and Provider Lifecycle. In the Exchange event I see two events recorded and event ID 6 and Event ID 8. I'm thinking it's a piping issue but I would think it would fail in both circumstances ad-hoc and as a task. Log Name: MSExchange Management Source: MSExchange CmdletLogs Date: 3/22/2013 1:09:38 PM Event ID: 8 Task Category: (1) Level: Error Keywords: Classic User: N/A Computer: UCMAILMGR.ad.uc.edu Description: The description for Event ID 8 from source MSExchange CmdletLogs cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer. If the event originated on another computer, the display information had to be saved with the event. The following information was included with the event: Log Name: MSExchange Management Source: MSExchange CmdletLogs Date: 3/22/2013 1:09:38 PM Event ID: 8 Task Category: (1) Level: Error Keywords: Classic User: N/A Computer: UCMAILMGR.ad.uc.edu Description: The description for Event ID 8 from source MSExchange CmdletLogs cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer. If the event originated on another computer, the display information had to be saved with the event. The following information was included with the event: 1620 5 Get-InboxRule Get-InboxRule System.InvalidOperationException: Operation is not valid due to the current state of the object. at Microsoft.Exchange.Data.Storage.ExchangePrincipal.get_ServerFullyQualifiedDomainName() at Microsoft.Exchange.Data.Storage.MailboxSession.Initialize(MapiStore linkedStore, LogonType logonType, ExchangePrincipal owner, DelegateLogonUser delegateUser, Object identity, OpenMailboxSessionFlags flags, GenericIdentity auxiliaryIdentity) at Microsoft.Exchange.Data.Storage.MailboxSession.<>c__DisplayClass12.<CreateMailboxSession>b__10(MailboxSession mailboxSession) at Microsoft.Exchange.Data.Storage.MailboxSession.InternalCreateMailboxSession(LogonType logonType, ExchangePrincipal owner, CultureInfo cultureInfo, String clientInfoString, IAccountingObject budget, Action`1 initializeMailboxSession, InitializeMailboxSessionFailure initializeMailboxSessionFailure) at Microsoft.Exchange.Data.Storage.MailboxSession.CreateMailboxSession(LogonType logonType, ExchangePrincipal owner, DelegateLogonUser delegateUser, Object identity, OpenMailboxSessionFlags flags, CultureInfo cultureInfo, String clientInfoString, PropertyDefinition[] mailboxProperties, IList`1 foldersToInit, GenericIdentity auxiliaryIdentity, IAccountingObject budget) at Microsoft.Exchange.Data.Storage.MailboxSession.ConfigurableOpen(ExchangePrincipal mailbox, MailboxAccessInfo accessInfo, CultureInfo cultureInfo, String clientInfoString, LogonType logonType, PropertyDefinition[] mailboxProperties, InitializationFlags initFlags, IList`1 foldersToInit, IAccountingObject budget) at Microsoft.Exchange.Data.Storage.MailboxSession.OpenAsAdmin(ExchangePrincipal mailboxOwner, MailboxAccessInfo accessInfo, LogonType logonType, CultureInfo cultureInfo, String clientInfoString, Boolean useLocalRpc, Boolean ignoreHomeMdb, Boolean recoveryDatabase) at Microsoft.Exchange.Data.Storage.MailboxSession.OpenAsAdmin(ExchangePrincipal mailboxOwner, CultureInfo cultureInfo, String clientInfoString, Boolean useLocalRpc, Boolean ignoreHomeMdb, GenericIdentity auxiliaryIdentity) at Microsoft.Exchange.Data.Storage.MailboxSession.OpenAsAdmin(ExchangePrincipal mailboxOwner, CultureInfo cultureInfo, String clientInfoString) at Microsoft.Exchange.Data.Storage.Management.XsoMailboxDataProviderBase..ctor(ExchangePrincipal mailboxOwner, String action) at Microsoft.Exchange.Data.Storage.Management.XsoMailboxDataProviderBase..ctor(ADSessionSettings adSessionSettings, ADUser mailboxOwner, String action) at Microsoft.Exchange.Management.RecipientTasks.InboxRuleDataProvider..ctor(ADSessionSettings adSessionSettings, ADUser mailboxOwner, String action) at Microsoft.Exchange.Management.RecipientTasks.GetInboxRule.CreateSession() at Microsoft.Exchange.Configuration.Tasks.DataAccessTask`1.InternalStateReset() at Microsoft.Exchange.Configuration.Tasks.GetTaskBase`1.InternalStateReset() at Microsoft.Exchange.Configuration.Tasks.GetTenantADObjectWithIdentityTaskBase`2.InternalStateReset() at Microsoft.Exchange.Management.RecipientTasks.GetInboxRule.InternalStateReset() at Microsoft.Exchange.Configuration.Tasks.Task.ProcessRecord() {401ae29a-ce8e-48a9-bf30-526dfc616029} the message resource is present but the message is not found in the string/message table Event Xml: <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event"> <System> <Provider Name="MSExchange CmdletLogs" /> <EventID Qualifiers="49152">8</EventID> <Level>2</Level> <Task>1</Task> <Keywords>0x80000000000000</Keywords> <TimeCreated SystemTime="2013-03-22T17:09:38.000000000Z" /> <EventRecordID>2325253</EventRecordID> <Channel>MSExchange Management</Channel> <Computer>UCMAILMGR.ad.uc.edu</Computer> <Security /> </System> <EventData> <Data>1620</Data> <Data>5</Data> <Data>Get-InboxRule</Data> <Data>Get-InboxRule</Data> <Data>System.InvalidOperationException: Operation is not valid due to the current state of the object. at Microsoft.Exchange.Data.Storage.ExchangePrincipal.get_ServerFullyQualifiedDomainName() at Microsoft.Exchange.Data.Storage.MailboxSession.Initialize(MapiStore linkedStore, LogonType logonType, ExchangePrincipal owner, DelegateLogonUser delegateUser, Object identity, OpenMailboxSessionFlags flags, GenericIdentity auxiliaryIdentity) at Microsoft.Exchange.Data.Storage.MailboxSession.<>c__DisplayClass12.<CreateMailboxSession>b__10(MailboxSession mailboxSession) at Microsoft.Exchange.Data.Storage.MailboxSession.InternalCreateMailboxSession(LogonType logonType, ExchangePrincipal owner, CultureInfo cultureInfo, String clientInfoString, IAccountingObject budget, Action`1 initializeMailboxSession, InitializeMailboxSessionFailure initializeMailboxSessionFailure) at Microsoft.Exchange.Data.Storage.MailboxSession.CreateMailboxSession(LogonType logonType, ExchangePrincipal owner, DelegateLogonUser delegateUser, Object identity, OpenMailboxSessionFlags flags, CultureInfo cultureInfo, String clientInfoString, PropertyDefinition[] mailboxProperties, IList`1 foldersToInit, GenericIdentity auxiliaryIdentity, IAccountingObject budget) at Microsoft.Exchange.Data.Storage.MailboxSession.ConfigurableOpen(ExchangePrincipal mailbox, MailboxAccessInfo accessInfo, CultureInfo cultureInfo, String clientInfoString, LogonType logonType, PropertyDefinition[] mailboxProperties, InitializationFlags initFlags, IList`1 foldersToInit, IAccountingObject budget) at Microsoft.Exchange.Data.Storage.MailboxSession.OpenAsAdmin(ExchangePrincipal mailboxOwner, MailboxAccessInfo accessInfo, LogonType logonType, CultureInfo cultureInfo, String clientInfoString, Boolean useLocalRpc, Boolean ignoreHomeMdb, Boolean recoveryDatabase) at Microsoft.Exchange.Data.Storage.MailboxSession.OpenAsAdmin(ExchangePrincipal mailboxOwner, CultureInfo cultureInfo, String clientInfoString, Boolean useLocalRpc, Boolean ignoreHomeMdb, GenericIdentity auxiliaryIdentity) at Microsoft.Exchange.Data.Storage.MailboxSession.OpenAsAdmin(ExchangePrincipal mailboxOwner, CultureInfo cultureInfo, String clientInfoString) at Microsoft.Exchange.Data.Storage.Management.XsoMailboxDataProviderBase..ctor(ExchangePrincipal mailboxOwner, String action) at Microsoft.Exchange.Data.Storage.Management.XsoMailboxDataProviderBase..ctor(ADSessionSettings adSessionSettings, ADUser mailboxOwner, String action) at Microsoft.Exchange.Management.RecipientTasks.InboxRuleDataProvider..ctor(ADSessionSettings adSessionSettings, ADUser mailboxOwner, String action) at Microsoft.Exchange.Management.RecipientTasks.GetInboxRule.CreateSession() at Microsoft.Exchange.Configuration.Tasks.DataAccessTask`1.InternalStateReset() at Microsoft.Exchange.Configuration.Tasks.GetTaskBase`1.InternalStateReset() at Microsoft.Exchange.Configuration.Tasks.GetTenantADObjectWithIdentityTaskBase`2.InternalStateReset() at Microsoft.Exchange.Management.RecipientTasks.GetInboxRule.InternalStateReset() at Microsoft.Exchange.Configuration.Tasks.Task.ProcessRecord()</Data> <Data>{401ae29a-ce8e-48a9-bf30-526dfc616029}</Data> </EventData> </Event> Log Name: MSExchange Management Source: MSExchange CmdletLogs Date: 3/22/2013 1:09:39 PM Event ID: 6 Task Category: (1) Level: Error Keywords: Classic User: N/A Computer: UCMAILMGR.ad.uc.edu Description: The description for Event ID 6 from source MSExchange CmdletLogs cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer. If the event originated on another computer, the display information had to be saved with the event. The following information was included with the event: Get-InboxRule {Mailbox=argusad} ad.uc.edu/Admins/exchangeadmin ConsoleHost-Local 1620 5 00:00:07.0607372 View Entire Forest: 'True', System.InvalidOperationException: Operation is not valid due to the current state of the object. at Microsoft.Exchange.Data.Storage.ExchangePrincipal.get_ServerFullyQualifiedDomainName() at Microsoft.Exchange.Data.Storage.MailboxSession.Initialize(MapiStore linkedStore, LogonType logonType, ExchangePrincipal owner, DelegateLogonUser delegateUser, Object identity, OpenMailboxSessionFlags flags, GenericIdentity auxiliaryIdentity) at Microsoft.Exchange.Data.Storage.MailboxSession.<>c__DisplayClass12.<CreateMailboxSession>b__10(MailboxSession mailboxSession) at Microsoft.Exchange.Data.Storage.MailboxSession.InternalCreateMailboxSession(LogonType logonType, ExchangePrincipal owner, CultureInfo cultureInfo, String clientInfoString, IAccountingObject budget, Action`1 initializeMailboxSession, InitializeMailboxSessionFailure initializeMailboxSessionFailure) at Microsoft.Exchange.Data.Storage.MailboxSession.CreateMailboxSession(LogonType logonType, ExchangePrincipal owner, DelegateLogonUser delegateUser, Object identity, OpenMailboxSessionFlags flags, CultureInfo cultureInfo, String clientInfoString, PropertyDefinition[] mailboxProperties, IList`1 foldersToInit, GenericIdentity auxiliaryIdentity, IAccountingObject budget) at Microsoft.Exchange.Data.Storage.MailboxSession.ConfigurableOpen(ExchangePrincipal mailbox, MailboxAccessInfo accessInfo, CultureInfo cultureInfo, String clientInfoString, LogonType logonType, PropertyDefinition[] mailboxProperties, InitializationFlags initFlags, IList`1 foldersToInit, IAccountingObject budget) at Microsoft.Exchange.Data.Storage.MailboxSession.OpenAsAdmin(ExchangePrincipal mailboxOwner, MailboxAccessInfo accessInfo, LogonType logonType, CultureInfo cultureInfo, String clientInfoString, Boolean useLocalRpc, Boolean ignoreHomeMdb, Boolean recoveryDatabase) at Microsoft.Exchange.Data.Storage.MailboxSession.OpenAsAdmin(ExchangePrincipal mailboxOwner, CultureInfo cultureInfo, String clientInfoString, Boolean useLocalRpc, Boolean ignoreHomeMdb, GenericIdentity auxiliaryIdentity) at Microsoft.Exchange.Data.Storage.MailboxSession.OpenAsAdmin(ExchangePrincipal mailboxOwner, CultureInfo cultureInfo, String clientInfoString) at Microsoft.Exchange.Data.Storage.Management.XsoMailboxDataProviderBase..ctor(ExchangePrincipal mailboxOwner, String action) at Microsoft.Exchange.Data.Storage.Management.XsoMailboxDataProviderBase..ctor(ADSessionSettings adSessionSettings, ADUser mailboxOwner, String action) at Microsoft.Exchange.Management.RecipientTasks.InboxRuleDataProvider..ctor(ADSessionSettings adSessionSettings, ADUser mailboxOwner, String action) at Microsoft.Exchange.Management.RecipientTasks.GetInboxRule.CreateSession() at Microsoft.Exchange.Configuration.Tasks.DataAccessTask`1.InternalStateReset() at Microsoft.Exchange.Configuration.Tasks.GetTaskBase`1.InternalStateReset() at Microsoft.Exchange.Configuration.Tasks.GetTenantADObjectWithIdentityTaskBase`2.InternalStateReset() at Microsoft.Exchange.Management.RecipientTasks.GetInboxRule.InternalStateReset() at Microsoft.Exchange.Configuration.Tasks.Task.ProcessRecord() at System.Management.Automation.CommandProcessor.ProcessRecord() 0 the message resource is present but the message is not found in the string/message table Event Xml: <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event"> <System> <Provider Name="MSExchange CmdletLogs" /> <EventID Qualifiers="49152">6</EventID> <Level>2</Level> <Task>1</Task> <Keywords>0x80000000000000</Keywords> <TimeCreated SystemTime="2013-03-22T17:09:39.000000000Z" /> <EventRecordID>2325254</EventRecordID> <Channel>MSExchange Management</Channel> <Computer>UCMAILMGR.ad.uc.edu</Computer> <Security /> </System> <EventData> <Data>Get-InboxRule</Data> <Data>{Mailbox=argusad}</Data> <Data>ad.uc.edu/Admins/exchangeadmin</Data> <Data> </Data> <Data> </Data> <Data>ConsoleHost-Local</Data> <Data>1620</Data> <Data> </Data> <Data>5</Data> <Data>00:00:07.0607372</Data> <Data>View Entire Forest: 'True', </Data> <Data>System.InvalidOperationException: Operation is not valid due to the current state of the object. at Microsoft.Exchange.Data.Storage.ExchangePrincipal.get_ServerFullyQualifiedDomainName() at Microsoft.Exchange.Data.Storage.MailboxSession.Initialize(MapiStore linkedStore, LogonType logonType, ExchangePrincipal owner, DelegateLogonUser delegateUser, Object identity, OpenMailboxSessionFlags flags, GenericIdentity auxiliaryIdentity) at Microsoft.Exchange.Data.Storage.MailboxSession.<>c__DisplayClass12.<CreateMailboxSession>b__10(MailboxSession mailboxSession) at Microsoft.Exchange.Data.Storage.MailboxSession.InternalCreateMailboxSession(LogonType logonType, ExchangePrincipal owner, CultureInfo cultureInfo, String clientInfoString, IAccountingObject budget, Action`1 initializeMailboxSession, InitializeMailboxSessionFailure initializeMailboxSessionFailure) at Microsoft.Exchange.Data.Storage.MailboxSession.CreateMailboxSession(LogonType logonType, ExchangePrincipal owner, DelegateLogonUser delegateUser, Object identity, OpenMailboxSessionFlags flags, CultureInfo cultureInfo, String clientInfoString, PropertyDefinition[] mailboxProperties, IList`1 foldersToInit, GenericIdentity auxiliaryIdentity, IAccountingObject budget) at Microsoft.Exchange.Data.Storage.MailboxSession.ConfigurableOpen(ExchangePrincipal mailbox, MailboxAccessInfo accessInfo, CultureInfo cultureInfo, String clientInfoString, LogonType logonType, PropertyDefinition[] mailboxProperties, InitializationFlags initFlags, IList`1 foldersToInit, IAccountingObject budget) at Microsoft.Exchange.Data.Storage.MailboxSession.OpenAsAdmin(ExchangePrincipal mailboxOwner, MailboxAccessInfo accessInfo, LogonType logonType, CultureInfo cultureInfo, String clientInfoString, Boolean useLocalRpc, Boolean ignoreHomeMdb, Boolean recoveryDatabase) at Microsoft.Exchange.Data.Storage.MailboxSession.OpenAsAdmin(ExchangePrincipal mailboxOwner, CultureInfo cultureInfo, String clientInfoString, Boolean useLocalRpc, Boolean ignoreHomeMdb, GenericIdentity auxiliaryIdentity) at Microsoft.Exchange.Data.Storage.MailboxSession.OpenAsAdmin(ExchangePrincipal mailboxOwner, CultureInfo cultureInfo, String clientInfoString) at Microsoft.Exchange.Data.Storage.Management.XsoMailboxDataProviderBase..ctor(ExchangePrincipal mailboxOwner, String action) at Microsoft.Exchange.Data.Storage.Management.XsoMailboxDataProviderBase..ctor(ADSessionSettings adSessionSettings, ADUser mailboxOwner, String action) at Microsoft.Exchange.Management.RecipientTasks.InboxRuleDataProvider..ctor(ADSessionSettings adSessionSettings, ADUser mailboxOwner, String action) at Microsoft.Exchange.Management.RecipientTasks.GetInboxRule.CreateSession() at Microsoft.Exchange.Configuration.Tasks.DataAccessTask`1.InternalStateReset() at Microsoft.Exchange.Configuration.Tasks.GetTaskBase`1.InternalStateReset() at Microsoft.Exchange.Configuration.Tasks.GetTenantADObjectWithIdentityTaskBase`2.InternalStateReset() at Microsoft.Exchange.Management.RecipientTasks.GetInboxRule.InternalStateReset() at Microsoft.Exchange.Configuration.Tasks.Task.ProcessRecord() at System.Management.Automation.CommandProcessor.ProcessRecord()</Data> <Data>0</Data> <Data> </Data> </EventData> </Event> Pete Pfefferkorn University of Cincinnati Information Technology Services Operating Systems Analyst/Messaging Administrator Phone: (513) 556-9076 Fax: (513) 556-2042 Email: pete.pfefferk...@uc.edu<mailto:pete.pfefferk...@uc.edu> --- To manage subscriptions click here: http://lyris.sunbelt-software.com/read/my_forums/ or send an email to listmana...@lyris.sunbeltsoftware.com<mailto:listmana...@lyris.sunbeltsoftware.com> with the body: unsubscribe exchangelist ************************************************************************************************** Note: The information contained in this message may be privileged and confidential and protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer. ************************************************************************************************** --- To manage subscriptions click here: http://lyris.sunbelt-software.com/read/my_forums/ or send an email to listmana...@lyris.sunbeltsoftware.com with the body: unsubscribe exchangelist