1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Windows Powershell help

Discussion in 'Software' started by Tigernos, 1 Nov 2016.

  1. Tigernos

    Tigernos Resident Roman Soldier

    Joined:
    12 Dec 2011
    Posts:
    315
    Likes Received:
    16
    Been a while since I've posted, I have come to beg for aid.

    I have a piece of software at work which is dumb as a bag of hammers (it can't do dates) so the boss has decided as a work around for scripts triggering at certain times, he has set the software to create a task in outlook. That way when the task is set to complete it will detect that change and move to its next piece of script.

    What I would like to do (I've been told it's possible) is to run a script in powershell that grabs all the tasks in outlook due on that day (today, run daily) and marks them all complete.

    Problem is I have never powershell'd in my life. Help?
     
  2. Tigernos

    Tigernos Resident Roman Soldier

    Joined:
    12 Dec 2011
    Posts:
    315
    Likes Received:
    16
    I've puzzled my way to connecting powershell to outlook and I can make it list tasks, I made a test task. So I can see the task, what do I need to write to make it edit and mark it complete?
     
  3. phuzz

    phuzz This is a title

    Joined:
    28 May 2004
    Posts:
    1,712
    Likes Received:
    27
    Could you paste the code you've got already?
    I've not got a copy of Outlook to test on, but there's a few examples that make it look quite straight forward.
    Assuming you already know the ID of the task you want to update, and you want to update the status you could use this:
    Code:
    $TaskToUpdate = New-Object -ComObject Outlook.Applicationsession.GetDefaultFolder(13).Items | Where-Object {$_.ID -eq "your task id here"}
    $TaskToUpdate.Status = "New status here"
    $TaskToUpdate.Save()
    You can see the other properties of task you can read/edit here.
    eg, to set the completed date as now
    Code:
    $TaskToUpdate.CompletedDateTime = Get-date -Format s
    $TaskToUpdate.Save()
    Disclaimer, I'm just guessing here, I've not tested any of this, and knowing my code there's at least half an hour of bug chasing in there ;)
     

Share This Page