Scheduled Powershell task not ending

I've set up a PS script to email users who are with in 14 days of their password expiring.  When I run it in PS it's self it runs fine, the notices go out and it ends.  However when I set it as a scheduled task it doesn't stop.  It starts,
sends the emails then Task scheduler says that it's still running an hour and a half later.  Normally it's a 5 min job.  I have it set to force stop after an hour, but it's ignoring that for some reason.  The job runs twice a day, and the action/program
is set as "Powershell noprofile -noexit -executionpolicy bypass -file C:\PasswordNotification.ps1"
THe scrip is as follows:
# Version 1.1 May 2014
# Robert Pearman (WSSMB MVP)
# TitleRequired.com
# Script to Automated Email Reminders when Users Passwords due to Expire.
# Requires: Windows PowerShell Module for Active Directory
# For assistance and ideas, visit the TechNet Gallery Q&A Page. http://gallery.technet.microsoft.com/Password-Expiry-Email-177c3e27/view/Discussions#content
# Please Configure the following variables....
$smtpServer="mail.forestriverinc.com.com"
$expireindays = 14
$from = "Password Notice <[email protected]>"
$logging = "Disabled" # Set to Disabled to Disable Logging
$logFile = "<D:\autoemail.csv>" # ie. c:\mylog.csv
$testing = "Disabled" # Set to Disabled to Email Users
$testRecipient = ""
$date = Get-Date -format ddMMyyyy
# Check Logging Settings
if (($logging) -eq "Enabled")
    # Test Log File Path
    $logfilePath = (Test-Path $logFile)
    if (($logFilePath) -ne "True")
        # Create CSV File and Headers
        New-Item $logfile -ItemType File
        Add-Content $logfile "Date,Name,EmailAddress,DaystoExpire,ExpiresOn"
} # End Logging Check
# Get Users From AD who are Enabled, Passwords Expire and are Not Currently Expired
Import-Module ActiveDirectory
$users = get-aduser -filter * -properties Name, PasswordNeverExpires, PasswordExpired, PasswordLastSet, EmailAddress |where {$_.Enabled -eq "True"} | where { $_.PasswordNeverExpires -eq $false } | where { $_.passwordexpired -eq $false }
$maxPasswordAge = (Get-ADDefaultDomainPasswordPolicy).MaxPasswordAge
# Process Each User for Password Expiry
foreach ($user in $users)
    $Name = (Get-ADUser $user | foreach { $_.Name})
    $emailaddress = $user.emailaddress
    $passwordSetDate = (get-aduser $user -properties * | foreach { $_.PasswordLastSet })
    $PasswordPol = (Get-AduserResultantPasswordPolicy $user)
    # Check for Fine Grained Password
    if (($PasswordPol) -ne $null)
        $maxPasswordAge = ($PasswordPol).MaxPasswordAge
    $expireson = $passwordsetdate + $maxPasswordAge
    $today = (get-date)
    $daystoexpire = (New-TimeSpan -Start $today -End $Expireson).Days
    # Set Greeting based on Number of Days to Expiry.
    # Check Number of Days to Expiry
    $messageDays = $daystoexpire
    if (($messageDays) -ge "1")
        $messageDays = "in " + "$daystoexpire" + " days."
    else
        $messageDays = "today."
    # Email Subject Set Here
    $subject="Your password will expire $messageDays"
    # Email Body Set Here, Note You can use HTML, including Images.
    $body ="
    **THIS IS AN AUTOMATICALLY GENERATED EMAIL, PLEASE DO NOT REPLY**<br>
    <br>
    Dear $name,
    <p> Your Password will expire $messageDays.<br>
    <p>To change your password on a FR owned computer connected to the company network press CTRL, ALT, Delete and chose Change Password.<br>
    After your password has been changed please LOG OUT of citrix and windows and log back in using the new password.
    <p>For outside users, log into mail.Forestriverinc.com, and in the upper right corner select Options,
    then Change Your Password in the drop down menu, when the page loads enter your old and new password. <br>
    <p>Thank you, <br>
    <p>Forest River IT Dept.<br>
    <p>**DO NOT REPLY TO THIS EMAIL, THIS IS AUTOMATICALLY GENERATED**
    </P>"
    # If Testing Is Enabled - Email Administrator
    if (($testing) -eq "Enabled")
        $emailaddress = $testRecipient
    } # End Testing
    # If a user has no email address listed
    if (($emailaddress) -eq $null)
        $emailaddress = $testRecipient    
    }# End No Valid Email
    # Send Email Message
    if (($daystoexpire -ge "0") -and ($daystoexpire -lt $expireindays))
         # If Logging is Enabled Log Details
        if (($logging) -eq "Enabled")
            Add-Content $logfile "$date,$Name,$emailaddress,$daystoExpire,$expireson"
        # Send Email Message
        Send-Mailmessage -smtpServer $smtpServer -from $from -to $emailaddress -subject $subject -body $body -bodyasHTML -priority High  
    } # End Send Message
} # End User Processing
# End

Hi,
Rather than picking through your code, I figured I'd just post what I use:
Import-Module ActiveDirectory
$users = Get-ADUser -Filter * -Properties PasswordLastSet,EmailAddress -SearchBase 'OU=Users,DC=domain,DC=com' | ForEach {
If ($_.PasswordLastSet -and $_.EmailAddress -and $_.GivenName -and $_.Surname) {
If ($_.DistinguishedName -notlike '*,OU=System,*' -and $_.DistinguishedName -notlike '*,OU=Administrator,*' -and $_.DistinguishedName -notlike '*,OU=Shared Resources,*' -and $_.SamAccountName -ne 'thebigboss') {
$passwordAge = ((Get-Date) - $_.PasswordLastSet).Days
If ($passwordAge -ge 106) {
If (120 - $passwordAge -ge 0) {
$props = @{
Name = $_.Name
GivenName = $_.GivenName
Surname = $_.Surname
Username = $_.SamAccountName
EmailAddress = $_.EmailAddress
PasswordLastSet = $_.PasswordLastSet
PasswordExpiresOn = (Get-Date $_.PasswordLastSet).AddDays(120)
DaysRemaining = 120 - $passwordAge
New-Object PsObject -Property $props
} | Sort Name
foreach ($user in $users) {
$daysLeft = $user.DaysRemaining
$emailBody = @"
Hello $($user.GivenName),
IMPORTANT REMINDER: Your *company* password will be expiring in $daysLeft days ($($user.PasswordExpiresOn.DateTime)).
Please change your password at your earliest convenience.
Procedure:
1 - Press Control+Alt+Delete on your keyboard (or Control+Alt+End if connected via VPN).
2 - Select 'Change a password...'.
3 - Type your current password and your new password twice.
4 - Press Enter or click the arrow button.
If you have any questions, please contact the helpdesk: [email protected]
Thank you.
*company* IT Department
If ($daysLeft -eq 14 -or $daysLeft -eq 10 -or $daysLeft -le 7) {
Send-MailMessage -To $user.EmailAddress -From [email protected] -Subject 'Password Expiration Notification' -Body $emailBody -SmtpServer smtp.domain.com -Bcc [email protected]
Send-MailMessage -To [email protected] -From [email protected] -Subject 'Password Expiration Notification Script Complete' -Body 'Script completed' -SmtpServer smtp.domain.com
Scheduled Task Action Properties:
Program/Script: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Add arguments: -File C:\Archive\Scripts\PasswordExpirationNotification\PasswordExpirationNotification.ps1
Don't retire TechNet! -
(Don't give up yet - 12,950+ strong and growing)

Similar Messages

  • Scheduled PowerShell Task

    I'd like to schedule a PowerShell task, have it pull 1 column of data from MySQL database and execute another PowerShell command on that data.  Is this possible?  Would you be kind enough to provide some sample code as I am new to both PS &
    MySQL.
    Or is it possible to schedule some sort of a job in MySQL to execute a PowerShell command?
    Thanks!
    www.ipUptime.net

    Hi All. I have a problem. I have many .ps1 files in a directory. I have to execute them all with an scheduled task. But i don´t know how to do that cause all the info that I have found is to make a scheduled task with justo only one .ps1 file and I need
    to execute more than one. Is there any way o do this??
    Thanks all
    Please start your own question instead of appending on to an old answered thread.
    Short answer - yes. Write a caller script and just schedule the caller.
    Don't retire TechNet! -
    (Don't give up yet - 12,950+ strong and growing)

  • ARD 3.1 Bug ? (task not ended)

    Hello,
    After updating to ARD 3.1 (from 3.0), I have some problems using unix task.
    with 3.0 when I send "softwareupdate -a -i" (using root user) to a group of computer, all update were made in parallel and when each task finised, I can see a green icon "success".
    with 3.1 after the task was send, I receive only "some times" the succes message
    the main part of tasks are labeled as active (despite the fact that the softwareupdate process has cleanlly ended on the client machine).
    I seems to be the "succesfull end" message was not send properly.
    Any idea ? bug ??
    Laurent

    I noticed a similar behavior when running softwareupdate earlier. Had you already upgraded the clients to 3.1?
    If you hadn't, then my guess would be that softwareupdate was updating the ARD client, thus interrupting the ARD session.

  • Powershell script not running in the task scheduler...

    I've created a .ps1 script to transfer a file using WinSCP can run it in the ISE environment, in the PS window, and with the run command. I've transferred the command I used in the run prompt to the task scheduler but it is not running. It is running everywhere
    else just not in the scheduler. It says that it completes okay and gives a return code of OpCode=2
    The action is set to run this: c:\Windows\System32\WindowsPowerShell\v1.0\Powershell.exe
    The Arguments: -ExecutionPolicy Bypass -file "C:\Users\me\scriptsWCP\FileTransferPS.ps1"
    Also have it running with the highest permission and as SYSTEM

    Hi,
    To run a powershell script with parameters in the Task Scheduler:
    Program: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
    Add argument (optional): -Command "& c:\scripts\test.ps1 -par1 2 -par2 3"
    Hope the below two articles be helpful for you:
    Schedule PowerShell Scripts that Require Input Values
    https://blogs.technet.com/b/heyscriptingguy/archive/2011/01/12/schedule-powershell-scripts-that-require-input-values.aspx
    How to Schedule a PowerShell Script
    http://dmitrysotnikov.wordpress.com/2011/02/03/how-to-schedule-a-powershell-script/
    Regards,
    Yan Li
    Regards, Yan Li

  • Firefox is very slow to respond when opening and nearly always stops responding altogether even refusing to react to Task Manager "End Program@ command. The "not responding@ error message also comes up during navigation on line.

    Firefox is very slow to respond when opening and nearly always stops responding altogether, even refusing to react to the Task Manager "End Program" command. The "not responding" error message also comes up during navigation on line. Several attempt have to be made to get on line. A loss of stability seems to be endemic at the moment.

    Try following the instructions here: [[Firefox hangs]]

  • Windows 2003 server scheduled tasks not work properly. Please help.

    I created a couple of windows shell scripting programs. When I call them from command line, it works well. Then I use Task Scheduler to schedule them to be run daily. The strange thing is: If I log into server and open Task Scheduler window. The scheduled tasks will run automatically and execute with result code 0x0. It works well. However, if I just set up Task Scheduler and log out of the server, the scheduled works will not run with result code 0x80. Here is the log info
    "programname-parametername.job" (programname.cmd)
     Started 1/28/2010 11:20:00 PM
    "programname-parametername.job" (programname.cmd)
     Finished 1/28/2010 11:20:00 PM
     Result: The task completed with an exit code of (80).
    I used windows adminstrator account, not system account to schedule the work. I changed scheduled work to be run by my admin account, not by system account. Please advise me where is the problem and how to fix it. Thanks in advance.

    Hi Polarisws,
    According to your description, I understand that your scheduled task did not run when the user is not logged in the system.
    Please go to the services.msc and select the "task Scheduler" service, double-click it and go to "Log On" page, enable the option "allow service to interact with desktop" and test the result.
    Regards,
    Wilson JiaThis posting is provided "AS IS" with no warranties, and confers no rights.

  • Process of Input Schedule is not ending

    Dear Experts
    I am inserting the data in Input schedule and after clicking on Send data.
    The Process of input schedule is not ending.
    Please help me,
    Thanks a lot in advance

    You have problem with send data (process of send is not finishing) when Send Governor process is not working any more.
    Restarting the OsoftSendGovernor process will probably solved the problem for a while but you have to investigate what was causing the fail of SG.
    Usually you have a problem with one dimension or the application server was overloaded...You have to do some investigation.
    Regards
    Sorin Radulescu

  • Coldfusion 10 Scheduled Tasks Not Working

    I'm trying to schedule a task that will run every Sunday. I have tried several options and I continue to get the following message...
    An error occured scheduling the task.
    Advance Scheduling support is not available in this edition of ColdFusion server.
    My version is the following..
    Server Product
    ColdFusion
    Version
    ColdFusion 10,283111
    Edition
    Standard  
    Operating System
    Windows Server 2008 R2
    OS Version
    6.1  
    Update Level
    /C:/ColdFusion10/cfusion/lib/updates/hf1000-3332326.jar  
    Adobe Driver Version
    4.1 (Build 0001)  
    I've updated with the Mandatory update and still have this issue. 
    Is there a work around or when should this be resolved?

    This fixed the issue... -Dhttp.proxyHost=wwwgate0.mot.com -Dhttp.proxyPort=1080  please note where to put the information.
    # VM configuration
    # Where to find JVM, if {java.home}/jre exists then that JVM is used
    # if not then it must be the path to the JRE itself
    java.home=C:\\ColdFusion10\\jre
    application.home=C:\\ColdFusion10\\cfusion
    # If no java.home is specified a VM is located by looking in these places in this
    # order:
    #  1) ../runtime/jre
    #  2) registry (windows only)
    #  3) JAVA_HOME env var plus jre (ie $JAVA_HOME/jre)
    #  4) java.exe in path
    # Arguments to VM
    java.args=-server -Xms256m -Xmx512m -XX:MaxPermSize=192m -XX:+UseParallelGC -Xbatch -Dcoldfusion.home={application.home} -
    Djava.awt.headless=true -Dcoldfusion.rootDir={application.home} -Djava.security.policy=
    {application.home}/lib/coldfusion.policy -Djava.security.auth.policy={application.home}/lib/neo_jaas.policy  -
    Dcoldfusion.classPath={application.home}/lib/updates,{application.home}/lib,{application.h ome}/lib/axis2,
    {application.home}/gateway/lib/,{application.home}/wwwroot/WEB-INF/cfform/jars,{applicatio n.home}/wwwroot/WEB-
    INF/flex/jars,{application.home}/lib/oosdk/lib,{application.home}/lib/oosdk/classes -Dcoldfusion.libPath=
    {application.home}/lib -Dorg.apache.coyote.USE_CUSTOM_STATUS_MSG_IN_HEADER=true -Dcoldfusion.jsafe.defaultalgo=FIPS186Random
    -Dhttp.proxyHost=wwwgate0.mot.com -Dhttp.proxyPort=1080
    # Comma separated list of shared library path
    java.library.path={application.home}/lib,{application.home}/jintegra/bin,{application.home }/jintegra/bin/international,
    {application.home}/lib/oosdk/classes/win
    java.class.path={application.home}/lib/oosdk/lib,{application.home}/lib/oosdk/classes

  • Scheduled Tasks Not working

    Hi All,
    I have an scheduled tasks on windows server 2008 standard, Which were working fine from couple of years.
    Now we are facing the issue of skipping the tasks without any error in history tab.
    " Next Run Time " is getting updated But the "Last Run Time" is in hold.
    We had tried troubleshooting following steps:
    1) Firstly, Windows update was cancelled & Restarted the server (Tasks started working fine with the End Result for 2 Days then Stopped)
    2)Deleted all the tasks & scheduled the tasks again then restarted (Tasks started working again with the final outcome for few days then Stopped Issue started again)
    Now we are confused and searched many Forums but we didn't find the solution.
    We have 7 Tasks which triggers an .EXE File. It Runs Manually & do the process.
    I have seen this System Task Running always "Certificate Services Client automatically manages digital identities such as Certificates, Keys and Credentials for the users and the machine, enabling enrollment,
    roaming and other services" is this might be the reason..
    Need the solution ASAP, I request all pro's to find me a solution.
    Thanks 

    Hi,
    Please check if there is a "CertificateServiceClient" in Task Scheduler.
    As you suspect it is the cause, test to disable "Certificate Services Client service" in Services.msc to see if issue still exists.
    If it is related, try to Increase the interval of SystemTask and UserTask under "CertificateServiceClient" in Task Scheduler to see if issue is affected. 
    If you have any feedback on our support, please send to [email protected]

  • Task does not end on completion event

    Hi,
    I have a workflow process made up of three tasks linked togheter with Exclusive Choices.
    If I open a workitem bound to a particular Task and then make the Web DynPro launch the event bound to signal the "Complete task" event, the Web Dynpro closes leaving the window only with the task header and the success message "Task succesfully completed".
    The problem is that sometimes the task is correctly terminated while other times the task is not ended at all! And every time the outcome is apparently random (i.e. task closed vs. task not closed).
    Do you have any idea of why this happens?
    Thank you,
    Pietro

    I've found the error that generates the problem: http://paste.lisp.org/+2OHA
    (TERMINATING_END_CONTROL_EVENT_Cancelled)
    Do someone has any idea of what this means?
    Thank you,
    Pietro

  • How to re-schedule wi's not executed

    Friends, one more doubt!
    I need to use a 3 stage re-schedule wi's not executed.
    That's it:
    If the analyst didn't executed the wi, I have to re-schedule it to his supervisor, and if the manager didn't executed its wi, re-schedule it to his manager.
    how can I do that ?

    Hi Glauco
    It's a bit difficult to explain in words, but simple once you get the hang of it.
    If you take a look at a dialog workflow task, you will see one tab labeled "Latest End".  In this tab you can schedule the task to automatically send a message to someone when it has not been completed after a certain amount of time (the deadline).  However, the current agent keeps the work item even if the deadline has passed.  This is called simple deadline monitoring.
    For extended deadline monitoring, you can not only schedule a message, but prompt the workflow to take action.  I don't know exactly how to configure it by hand, but you can find a wizard for creating the extended steps in the Workflow Builder.  The wizard can be found under the Workflow Wizards section of SWDD, on the lower-left hand side of the screen.  You can select this tab the same way you change from viewing the workflow containers to "Step Types that can be inserted" tab.
    I hope I was a bit clearer this time.
    Regards.
    Juan Ramos

  • Scheduled jobs are not running DPM 2012 R2

    Hi,
    Recently upgraded my dpm 2012 sp1 to 2012 R2 and upgrade went well but i got 'Connection to the DPM service has been lost.(event id:917 and other event ids in the eventlog errors ike '999,997)'. Few dpm backups are success and most of the dpm backups consistenancy
    checks are failed.
    After investigating the log files and found two SQL server services running in the dpm 2012 r2 server those are 'sql server 2010 & sql server 2012 'service. Then i stopped sql 2010 server service and started only sql server 2012 service using (.\MICROSOFT$DPM$Acct).
    Now 'dpm console issue has gone (event id:917) but new issue ocurred 'all the scheduled job are not running' but manully i can able to run all backup without any issues. i am getting below mentioned event log errors 
    Log Name:      Application
    Source:        SQLAgent$MSDPM2012
    Date:          7/20/2014 4:00:01 AM
    Event ID:      208
    Task Category: Job Engine
    Level:         Warning
    Keywords:      Classic
    User:          N/A
    Computer:      
    Description:
    SQL Server Scheduled Job '7531f5a5-96a9-4f75-97fe-4008ad3c70a8' (0xD873C2CCAF984A4BB6C18484169007A6) - Status: Failed - Invoked on: 2014-07-20 04:00:00 - Message: The job failed.  The Job was invoked by Schedule 443 (Schedule 1).  The last step to
    run was step 1 (Default JobStep).
     Description:
    Fault bucket , type 0
    Event Name: DPMException
    Response: Not available
    Cab Id: 0
    Problem signature:
    P1: TriggerJob
    P2: 4.2.1205.0
    P3: TriggerJob.exe
    P4: 4.2.1205.0
    P5: System.UnauthorizedAccessException
    P6: System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal
    P7: 33431035
    P8: 
    P9: 
    P10: 
    Log Name:      Application
    Source:        MSDPM
    Date:          7/20/2014 4:00:01 AM
    Event ID:      976
    Task Category: None
    Level:         Error
    Keywords:      Classic
    User:          N/A
    Computer:      
    Description:
    The description for Event ID 976 from source MSDPM 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: 
    The DPM job failed because it could not contact the DPM engine.
    Problem Details:
    <JobTriggerFailed><__System><ID>9</ID><Seq>0</Seq><TimeCreated>7/20/2014 8:00:01 AM</TimeCreated><Source>TriggerJob.cs</Source><Line>76</Line><HasError>True</HasError></__System><Tags><JobSchedule
    /></Tags></JobTriggerFailed>
    the message resource is present but the message is not found in the string/message table
    plz help me to resolve this error.
    jacob

    Hi,
    i would try to reinstall DPM
    Backup DB
    uninstall DPM
    Install DPM same Version like before
    restore DPM DB
    run dpmsync.exe -sync
    finished
    Seidl Michael | http://www.techguy.at |
    twitter.com/techguyat | facebook.com/techguyat

  • Firefox won't close without using Task Manager - end process; can't start in safe mode or disable add-ons

    I've been having a memory leak/hanging problem for weeks -- FF slowly increases memory usage until it's at almost 100% and then freezes and I have to shut it down via Task Manager/end process.
    Last week I updated to FF 12, and I also added the Web Developer 1.1.9 add-on. Now every time I open Firefox it tries to go to the "Web Developer installed" page, but the page never loads. Nothing else will load either.
    I can't start in Safe Mode because of the problem with having to close it in Task Manager. I select "restart with add-ons disabled" and it just never opens. The Add-On manager page won't load, so I can't disable Web Developer to see if that's the problem.
    I've uninstalled Firefox and reinstalled, and it still goes right back to the Web Developer page when I open the freshly installed copy.
    Help, please!

    Have you already tried clearing the browser cache, opening a blank tab, and trying to open some other website ?
    * [[how to clear the cache]]
    Instead of trying to open safe mode from within the User Interface menu have you tried alternative methods such as holding the shift key when you start Firefox. (After checking for running Firefox processes or plugincontainer and killing them if found )
    * see [[safe mode]]
    * [[firefox hangs]]
    If using safemode does not help first of all try creating and using a new profile.
    * [[Basic Troubleshooting#w_8-make-a-new-profile]]_8-make-a-new-profile
    If all the above fail then try a clean re-install of Firefox
    * [[Basic Troubleshooting#w_7-reinstall-firefox]]_7-reinstall-firefox

  • Excel process does not end properly

    Hello All.
    I am using excel in my program writing data into it an excel workbook and then later on reading data from it. I have written down the code of closing excel worlkbook and shutting down excel application hence releasing the handles for it. But when i do that i.e. when the code containing excel workbook closing and excel application shutting down executes, excel workbook is closed but excel process does not end properly and can be seen in the task manager. And when i repeatedly open the excel file through my front end interface and close the file, another excel process is added in the task manager which does not end and so on. What can be the problem and solution. Thanks in advance.
    Best Regards.
    Moshi.

    Interfacing to Excel via ActiveX may be tricky, ending in situations like the one you are facing now.
    The basic principle is that every single handle opened to an Excel object (workbook, worksheet, range, variant and so on) must be closed properly for the entire process to terminate gracefully. If a reference remains unhandled at program end you will find an instance of Excel remaining in the task list and you may suffer erratic behaviour in subsequent accesses to the product.
    You must double check all references and add approporiate dispose/close commands for every one of them.
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • Applescript to make task note part of task name

    If I have a task say
    Do this
    Task Note - @work
    Is it possible for me to dump the task note @work to task name and name becomes
    Do this @work
    Can this be done for all my tasks.

    Your request is a bit vague, but see the script below. I suggest that you backup your iCal before running this in case you don't like the result. Change the calendar to the one you want.
    -- John Maisey -- www.nhoj.co.uk -- 29 Mar 2010
    -- This script gets all todos in the specified calendar and moves their notes that contain the requires text into the title.
    set calendarName to "Home"
    set theText to "@work"
    tell application "iCal"
    set myTodos to (todos of calendar calendarName)
    repeat with myTodo in myTodos
    if (description of myTodo) contains theText then
    set (myTodo's summary) to (myTodo's summary) & " " & theText
    end if
    end repeat
    end tell
    Best wishes
    John M

Maybe you are looking for