Exchange 2010 task scheduled scripts not working if not logged on

Hi All,
I have done a script for Exchange 2010 and I would like to create a scheduled task for it.
I have followed the guidance of Mike Pfeiffer's blog.
http://www.mikepfeiffer.net/2010/02/creating-scheduled-tasks-for-exchange-2010-powershell-scripts/
However when I set the task as  “Run whether user is logged on or not”, it only works if the user running the task is the administrator. The task is run with high privileges.
If I do it with a service account (local admin, exchange org admin) it works only when:
-You run the script for an interactive session of the user or a runas cmd
-You set the Task as “Run only when the user is logged on” (and the user is logged on)
If I run the Task as “Run whether user is logged on or not” and the user is not logged on, I get an error on the connection command "Connect-ExchangeServer -auto" (and the task hangs waiting for an answer). The transcript is as follows:
Transcript started, output file is C:\scripts\informes\pruebasconexion.Log.txt
         Welcome to the Exchange Management Shell!
Full list of cmdlets: Get-Command
Only Exchange cmdlets: Get-ExCommand
Cmdlets that match a specific string: Help *<string>*
Get general help: Help
Get help for a cmdlet: Help <cmdlet name> or <cmdlet name> -?
Show quick reference guide: QuickRef
Exchange team blog: Get-ExBlog
Show full output for a command: <command> | Format-List
Tip of the day #31:
Tab completion reduces the number of keystrokes required to complete a cmdlet. Just press the TAB key to complete the cmdlet you are typing. Tab completion kicks in whenever there is a hyphen (-) in the input. For example:
 Get-Send<tab>
should complete to Get-SendConnector. You can even use wildcards, such as:
 Get-U*P*<tab>
Pressing the TAB key when you enter this command cycles through all cmdlets that match the expression, such as the Unified Messaging Mailbox policy cmdlets.
WARNING: The service  () isn't running. Connecting to remote Powershell requires this service to be running.
VERBOSE: Connecting to CAS01.XXX.es
 An internal error occurred. 
    + CategoryInfo          : InvalidArgument: (http://cas01.XX...Ver=14.1.218.15:Uri) [], PSInvalidOperationException
    + FullyQualifiedErrorId : CreateRemoteRunspaceFailed
VERBOSE: Connecting to CAS02.XXX.es
An internal error occurred. 
    + CategoryInfo          : InvalidArgument: (http://cas02.XX..Ver=14.1.218.15:Uri) [], PSInvalidOperationException
    + FullyQualifiedErrorId : CreateRemoteRunspaceFailed
WARNING: The service  () isn't running. Connecting to remote Powershell requires this service to be running.
VERBOSE: Connecting to MBX02.XXX.es
An internal error occurred. 
    + CategoryInfo          : InvalidArgument: (http://mbx02.XX...Ver=14.1.218.15:Uri) [], PSInvalidOperationException
    + FullyQualifiedErrorId : CreateRemoteRunspaceFailed
VERBOSE: Connecting to CAS01.XXX.es
An internal error occurred. 
    + CategoryInfo          : InvalidArgument: (http://cas01.XX...Ver=14.1.218.15:Uri) [], PSInvalidOperationException
    + FullyQualifiedErrorId : CreateRemoteRunspaceFailed
VERBOSE: Connecting to CAS02.XXX.es
An internal error occurred. 
    + CategoryInfo          : InvalidArgument: (http://cas02.XX...Ver=14.1.218.15:Uri) [], PSInvalidOperationException
    + FullyQualifiedErrorId : CreateRemoteRunspaceFailed
WARNING: The service  () isn't running. Connecting to remote Powershell requires this service to be running.
VERBOSE: Connecting to MBX02.XXX.es
An internal error occurred. 
    + CategoryInfo          : InvalidArgument: (http://mbx02.XX...Ver=14.1.218.15:Uri) [], PSInvalidOperationException
    + FullyQualifiedErrorId : CreateRemoteRunspaceFailed
Failed to connect to an Exchange server in the current site.
Enter the server FQDN where you want to connect.:
The error message refers to a unkown "() service", but I have no clue of which service can be needed and it is working only when session is opened.
 The command I run is
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command ". 'c:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1';c:\scripts\informes\estado_db_dag.ps1"
UNICAN-SdeI

I experienced a similar symptom where the scheduled task was getting stuck in the "Running" state. I searched the web for others who have experienced this issue with scheduled tasks, and what I found is that there could be a few reasons why
this might happen. 
I resolved my problem by adding -NonInteractive switch before the -command parameter.
Hope it helps...
In my case, -NonInteractive does indeed stop the task from getting stuck in a perpetual Running state (until it times out based on the settings in scheduled task), but I was able to deduce why by using Start-Transcript and Stop-Transcript.
Basically, the connection to Exchange is failing some reason and it sits at a prompt waiting for you to enter a FQDN for an Exchange server (same problem as the OP).  Adding -NonInteractive to the scheduled task does indeed prevent the task from getting
stuck waiting for someone to enter a FQDN at a prompt that they cannot interact with, the script still does not execute correctly.  Essentially, adding the "-NonInteractive" switch does not fix the underlying problem of the Exchange connection
failing.
As far as I am able to tell, this has something do with a WinRM problem.  I'm having the same problem as the OP and am trying to troubleshoot it.  In my case, deleting the user profile for the service account does not fix the problem.

Similar Messages

  • Task Scheduling Script - Need help with passing the scheduled command (variables are not being evaluated)

    Hi Everyone,
    I'm trying to get a simple task scheduler script to work for me and can't get the command I need passed to the scheduler to evaluate properly.
    Here's the script:
    ###Create a new task running $Command and execute it Daily at 6am.
    $TaskName = Read-Host 'What would you like this job to be named?'
    $Proto = Read-Host 'What is the protocol? (FTP/FTPS/SFTP)'
    $User = Read-Host 'What is the user name?'
    $Pwd = Read-Host 'What is the password?'
    $Server = Read-Host 'What is the server address?'
    $NetworkDir = Read-Host 'Please input the network location of the file(s) you wish to send. Refer to documentation for more details.'
    $RemoteDir = Read-Host 'Please input the REMOTE directory to which you will upload your files. If there is none please input a slash'
    $Command = 'winscp.com /command "option batch abort" "option confirm off" "open $Proto://$User:$Pwd@$Server" "put $NetworkDir $RemoteDir" "exit"'
    $TaskAction = New-ScheduledTaskAction -Execute "$Command"
    $TaskTrigger = New-ScheduledTaskTrigger -Daily -At 6am
    Register-ScheduledTask -Action $TaskAction -Trigger $Tasktrigger -TaskName "$TaskName" -User "Administrator" -RunLevel Highest
    Write-Host "$TaskName created to run Daily at $TaskStartTime"
    What's messing up is the $Command creation, the command needs to have the quotes around "option blah blah", but if I wrap the whole line in single quotes the variables that are evaluated for the "open blah blah" strings (which also need
    to be inside quotes) and the "put blah blah" string are not being evaluated properly.
    I've dorked about with different bracketing and quoting but can't nail the syntax down, could someone point me in the right direction? My Google-fu seems to be lacking when it comes to nailing down this issue.
    Thanks

    Hmmn, closer. I'm getting this error now:
    + $Command = $tmpl -f  $User, $Pwd, $Server, $NetworkDir, $RemoteDir
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (winscp.com /com...t {4} {5}" exit:String) [], RuntimeException
        + FullyQualifiedErrorId : FormatError
    And the command being added to the new task looks like this:
    winscp.com /command "option batch abort" "option confirm off" "open ($Proto)://($User):($Pwd)@($Server)" "put $NetworkDir $RemoteDir" "exit"
    Here's the current state of the script. I get what you're doing to try to bypass the quotes issue, using an array. I'm just not awesome at this yet sooooooo...
    $TaskName = Read-Host 'What would you like this job to be named?'
    $Proto = Read-Host 'What is the protocol? (FTP/FTPS/SFTP)'
    $User = Read-Host 'What is the user name?'
    $Pwd = Read-Host 'What is the password?'
    $Server = Read-Host 'What is the server address?'
    $NetworkDir = Read-Host 'Please input the network location of the file(s) you wish to send. Refer to documentation for more details.'
    $RemoteDir = Read-Host 'Please input the REMOTE directory to which you will upload your files. If there is none please input a slash'
    $tmpl = 'winscp.com /command "option batch abort" "option confirm off" "open {0}://{1}:{2}@{3}" "put {4} {5}" exit'
    $Command = $tmpl -f $User, $Pwd, $Server, $NetworkDir, $RemoteDir
    $TaskAction = New-ScheduledTaskAction -Execute $Command
    $TaskTrigger = New-ScheduledTaskTrigger -Daily -At 6am
    Register-ScheduledTask -Action $TaskAction -Trigger $Tasktrigger -TaskName "$TaskName" -User "Administrator" -RunLevel Highest
    Write-Host "$TaskName created to run Daily at $TaskStartTime"

  • Issue with Update Rollup 5 for Exchange 2010 SP3 - Mailboxes that were auto mapped not working

    Below is  my response in another thread but creating a new one in the hopes that someone has the same issue and a solution besides mine below.
    Ever since we installed Update Rollup 5 for SP3 Exchange 2010 mailboxes that were auto mapped are not accessible. They all get the same error.
    Cannot expand the folder. The set of folders cannot be opened. The attempt to log on to the Microsoft Exchange has failed.
    What I have been doing is removing the users permission, then adding them back using the noautomap switch in Powershell. After doing that, the user manually adds the mailbox and all is well.
    Just a note here, I suspect it may have something to do with the version of Outlook 2010. We are running an older version here. I think only SP1 with no other incremental updates. Office is up to SP2. Also, one of the users I was working with could not access
    the mailbox no matter what we tried but she can walk over to another workstation and open Outlook and access the very same mailbox so that pretty much proves its software related particularly with Outlook.
    I cannot reproduce the problem on a workstation (XP) with a newer version of Outlook.
    This has been wearing me out and I suspected the Update Rollup all long. Now I am confident as others are having the same problem. If you find out anything on how to fix this other than the steps above, let me know.

    Not sure why it was suggested to use the auto mapping feature to grant permissions because that is the component that is causing the issue. Also, there is nothing wrong with the auto configuration because the user can access their own mailbox just fine and
    also select mailboxes in their Outlook that were NOT auto mapped.
    With that said, here is how I fixed them all.
    Remove the permissions using the Exchange Console. Don't forget Send As
    Wait about 15 minutes. The mailbox should disappear from the users Outlook
    Open an Exchange PowerShell window and run the following command:
    .\add-mailboxpermissionsnoautomap.ps1 -Identity mailbox -User user -AccessRights FullAccess
    Have the user add the mailbox to their Outlook using the manual process.
    All is well....
    If you don't have the PS script add-mailboxpermissionsnoautomap.ps1, you can download it. I stumbled across it a few years ago and use it all the time. If you can't find it, just use the Exchange built in command for adding mailbox folder permissions but
    specify automap $false.
    The idea here is to grant the user access without auto mapping.

  • Not working anything not charging no conection with pc and if call me the tell that i am not answering

    Not working anything not charging no conection with pc and if somebody calls me it tells that i am not answering
    That thing that just happended whith my iphone and now i can not do anything whith my iphone it just turned off

    Yes, you got the phone which was currently eligible for Early Edge at the time. This changes from time to time. When the iPhone 6/6+ was first released those were the ONLY phones you could purchase on Early Edge. This was for September and October of 2014. You would not have been able to purchase any other phone with Early Edge at the time. At the time, this made a lot of android phone owners angry, just as it is making the OP(an iPhone owner) angry now. Then it was the Droid Turbo ONLY, then it was....
    One of the requisites AS LISTED ON THE EDGE PAGE is that your line must be eligible for an upgrade. Verizon lifts this requirement IF you want to purchase a specific phone. If the phone you want is not eligible for Early Edge at this moment, it may be at some point in the future and the phone CURRENTLY available may NOT be available for Early Edge. You were able to get the phone you wanted on Early Edge because it was the phone(or one of the phones) eligible at the time for Early Edge.
    Verizon does not have a link for Early Edge because it is not always available AND the eligible phones change from time to time. This is no different than any other special they occasionally run.
    Regardless, since a link WAS given for Edge which DOES list upgrade eligibility as being a requirement, if someone DOES NOT fulfill that requirement it is not out of the question that other portions of Edge may be different, too, such as what you posted "All Verizon Wireless smartphones, tablets and basic phones are eligible for Verizon Edge." If Verizon relaxes a requirement to enter into Edge, why is it so hard to fathom they may ALSO change something else such as which phones are eligible???
    The fact that the OP IS NOT able to purchase an iPhone on Early Edge simply reinforces this fact.

  • HT1766 # is not working in my iphone 4s, when i want to see how much credit i have in iphone, i need to put # on that, than it calls and end, it is not working and not showing anything..

    # is not working in my iphone 4s, when i want to see how much credit i have in iphone, i need to put # on that, than it calls and end, it is not working and not showing anything..

    http://support.apple.com/kb/HT1848  Did you transfer your purchased item, take a look at the link

  • TS1398 when i update my software to 6.1.3(10B329)to I phone 4s the wifi is not working and not auto join the network that i have already connected to

    when i update my software to 6.1.3(10B329)to I phone 4s the wifi is not working and not auto join the network that i have already connected to

    First, grow up.  Just because YOUR phone isn't working, doesn't mean Apple put out bad software.  I've not had any difficulty, nor has anyone else I know.  And just how is Apple risking lives with Bluetooth kits not working?  It's YOUR decision to talk on the phone or text and drive.  Not Apple's.
    We're users here, volunteering our time to help others.  Posts like yours, which are whiny and ranting, simply means we're likely to ignore you and not provide you with any help.  Not to mention, it makes you look absolutely foolish.
    Further making you look foolish is the fact that you haven't even asked a technical support question, nor have you provided anyone here with any troubleshooting steps you might have taken, including those recommended in the user guide.
    Good luck getting help.
    GDG

  • I just bought a power adapter and it is not working, says "not charging".   The same for the mobile charger.   Anything I need to do in the setting?

    I just bought a power adapter and it is not working, says "not charging".   The same for the mobile charger.   Anything I need to do in the setting?

    The device is locked to the carrier it was purchased through unless you specifically purchased it as unlocked directly from Apple.
    Only the carrier to whom it is locked can authorize it's unlocking.  To do so, the user much contact them to start the unlock process.

  • My Iphone 5 headset is not working?Not able to hear sound (for eg:Music)

    My Iphone 5 headset is not working?Not able to hear sound (for eg:Music)

    Try disconnecting the headphones and then adjusting the volume, does it say headphones?
    There might be something in the headphone jack, maybe lint, dirt, or something else in there.
    Take a look at this Apple document for more information -> iPhone: Can't hear through the receiver or speakers

  • Iphone not work i can only see the APPLE NOT WORK, iphone not work i can only see the APPLE NOT WORK

    iphone not work i can only see the APPLE NOT WORK, iphone not work i can only see the APPLE NOT WORK

    First, try to reset by holding the sleep and home button for about 10sec, until the Apple logo comes back again.
    If this does not help, connect in recovery mode and restore, explained in this article: iOS: Unable to update or restore

  • Can't sync ical on my iphone and imac. email and note work but not ical.  can anyone help.

    can't sync ical on my iphone and imac. email and note work but not ical.  can anyone help.
    thanks
    bmoreimac

    So how can i make it work that way, i asked one of my friends, and she says it works like that...when she delete the email on her iphone it is deleted on the mac too, what do i do to change this?....my mail it's hotmail, i don't know if its relevant

  • HT4993 why does my internet not work when not connected to wifi?

    why does my internet not work when not connected to wifi

    Hi farmgirl0812,
    Thanks for using Apple Support Communities.  This article has steps to try if you are unable to connect to a cellular network:
    iPhone: Troubleshooting a cellular data connection
    http://support.apple.com/kb/ts3780
    Cheers,
    - Ari

  • TS2755 the pic butten on messages is not working. can not send or recieve photos. please help.

    the pic butten on messages is not working. can not send or recieve photos. please help.

    Hi Beharley,
    try resetting your network settings: Settings - General - Reset - Reset Network Settings. This works fine if something is messed up with your carrier bundle.
    Regards, Peter

  • On my iPhone 5, Siri is not working on notes. How do I fix this?

    Siri is not working in notes. How can I fix this?

    Clear the cache and the cookies from sites that cause problems.
    "Clear the Cache":
    *Tools > Options > Advanced > Network > Cached Web Content: "Clear Now"
    "Remove Cookies" from sites causing problems:
    *Tools > Options > Privacy > Cookies: "Show Cookies"
    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
    *Do NOT click the Reset button on the Safe mode start window or otherwise make changes.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • I bought all the episodes - full episode Sally - the amount of 11.99 dollars did not work did not carry episodes

    I bought all the episodes - full episode Sally - the amount of 11.99 dollars did not work > Can not download episodes
    سالي كل الحلقات/ سالي الحلقة الكاملة
    date 12/3/2012
    order: M1vyql3kk9
    Please return the amount to the account, the amount Aotaubi buy other products

    Log into your iTunes account, click on your name,
    select Account from the dropdown list, on the Account
    page, select Purchase History and click on the arrow
    to the right to see what you bought and when. If you spent
    more than you had on the account, it was charged to your
    credit card. Check your credit card bill online at your
    financial institution to see if you were billed for anything.

  • Have Mail Version 4.6 (1085), is not working properly not receiving mail.  I sent a test message to my computer; it took over an hour delivering.

    Have Mail Version 4.6 (1085), is not working properly not receiving mail.  I sent a test message to my computer; it took over an hour delivering. There are multiple copies of messages appearing in the recovered folder
    My computer is a MacBook, version osx 10.6.8
    All help appreciated
    <E-mail Edited by Host>

    Hi vin rouge,
    Welcome to the Support Communities!
    The article below may be able to help you with this issue.
    Click on the link to see more details and screenshots.
    OS X Mail: Troubleshooting sending and receiving email messages
    http://support.apple.com/kb/TS3276
    Configuring Mail for your email account 
    http://support.apple.com/kb/HT1277
    Cheers,
    - Judy

Maybe you are looking for

  • Credit note

    Dear All, When the customer returns goods,the basis for calculating the price in returns should be on  the billing date of the main invoice.like if customer returns goods  in the same month the price should be as in billing document (say 40,000)  if 

  • Post-install of SSM 4.0 and client-copy

    We finished the installation of Sol. Man. 4.0 on a linux/oracle platform.  At what point in the post install do we do the client copy of client 000 for data and client 001 for users to a new client? Before, during or after all the img config in 000?

  • AAE - Error -  Unable to retrieve MappingInterfaceLocalHome from JNDI while

    Hi Friends, We have an interface which runs in AAE.  (Advanced Adapter Engine, PI 7.1, EHP1) Sender is SOAP, Async Call. We have used the condition to determine receiver. One Receiver is SOAP (by remove proxy) and another one receiver is RFC. When we

  • Can i recieve service in Guatemala? Have problem home button and front camera

    Hi guys I'm user of ipod touch 4th generation i bought this in may 2011 And i paid apple care in applestore Glendale L. A CA. Now i live in Guatemala and my ipod have problem of home button And front camera(camera problem started when i bought) What

  • Fact and dimension table relationship?

    hi in se38 i executed this program sap_infocube_designs i got all cubes and percentage , this is directly fact and dimension table relationship based on this i need to take action is it line item dimension or high cardinality (dimen>20% fact line, di