none
Update Incidents by email RRS feed

  • Question

  • I have followed anders blog (great work here Anders, and Patrick) its at contoso.se for those who don't know yet

     

    I have implemented the Update Incidents by e-mail blog posting, and its all working except the bit to update the incidents.

     

    I can see the incidents move from the newSCSM to the updateSCSM folders but the incident is not updated?

     

    Any one else had any luck with this???

     

     

     

    Tuesday, June 15, 2010 1:24 PM

Answers

  • Ok here is what i had to do to get this working;

     

    Manually created the scripts, 

    set the execution policy to unrestricted

    edited the profile.ps1 to automatically add in the snap ins

    changed the ps1 script to only contain the following;

    Set-SCSMIncident -ID $args[0] -Comment $args[1] -AttachmentPath $args[2]

    write-host $args[0]

    write-host $args[1]

    write-host $args[2]


    and it work's without error

    I am running Outlook 2010, so i had to make some manual changes to the registry files as they are not the same for 2010 ans it uses the eml.14 extension


    Thanks Patrick, Anders scripts are great.

    Thursday, June 17, 2010 4:08 PM

All replies

  • Hi, the VBscript that updates incidents should find a IR number or the string you search for in the e-mail. In my example it looks for Contoso-IRXX. It thens split that variable to get the IR number. It then runs the powershell script to do the update. You could add a vbscript.echo in the end of the VBscript to echo varIncident to make sure it has a correct incident IR number. You could also run add a line to the powershell script that echo to a file, so yu can see all parameters that the power shell script runs with.
    Anders Bengtsson | Microsoft MVP - Operations Manager | http://www.contoso.se
    Tuesday, June 15, 2010 7:25 PM
    Answerer
  • are you able to explain a little further ie. what should the vbs/powershell be updated to?
    Tuesday, June 15, 2010 7:27 PM
  • If you in the update.vbs script add Wscript.Echo pscommand on a new line after executor.StdIn.Close, and run the vb script from a command prompt you should get a popup showing the parameter that the vbscript is forwarding to the power shell script. That is a good start. Then we can see if it manage to get a correct incident ID.
    Anders Bengtsson | Microsoft MVP - Operations Manager | http://www.contoso.se
    Wednesday, June 16, 2010 10:06 AM
    Answerer
  • Hi,

    I have a quick question regarding this subject. Your VB scripts works fine but I have a problem with the Get-SCSMIncident cmdlet. When I try to search incidents with different parameters I don't get any results. Powershell only shows this message: WARNING: Found no incidents. Any idea where the  Get-SCSMIncident try to find those incidents? Does it point to wrong place in my system or what? SCSM installation is default.

    Thanks in advance - Mikko Pohjonen

    Wednesday, June 16, 2010 11:42 AM
  • C:\Scripts\update.ps1 IR118 'Update from end-user email"

    E:\SCSMmail\UpdateSCSM\89a8071c01cb0d590000000c.eml

     

    This is not the correct IR as the IR is called Contoso-IR118 not IR118.

     

    then i get the security warning in the cmd prompt

     

    Security Warning

    Run only scripts that you trust. While Scripts from the Internet can be useful this script can potentially harm your computer. do you want to tun C:\scripts\update.ps1

    [D] Do not run [R] Run Once [S] Suspend [?] Help <default is "D">:

    I choose R

    Wednesday, June 16, 2010 1:46 PM
  • Hi guys!

    Glad to see that the powershell cmdlets are beeing used :)

    Security warnings are based on the execution policy. To get more information about this, open a powershell window and write: "get-help about_execution_policies".
    Mikko: Could you pls give me the full command line that doesn't work for you?


    Patrik Sundqvist Solutions Architect @ Atea Spintop http://blogs.litware.se
    Thursday, June 17, 2010 9:56 AM
    Moderator
  • I am nearly there with getting this to work, as soon as I am done I will post the steps I have done to resolve,  but it took some editing of the script, some editing of the powershell to resolve, I just want to test it before I post the steps taken

     

    Thursday, June 17, 2010 1:52 PM
  • Hi!

    Thanks for your reply Patrik. I already solved my problem. It was once again just a stupid end user (me) :). I was using the computer as admin but I my account didn't have admin privileges on SCSM. Get-SCSMIncident cmdlet could not find anything because there wasn't any incidents. Now I have admin privileges on SCSM and your script works perfectly. I have another question for you if you don't mind. Does the -Status parameter accept only default status values? I have added few own statuses (working,waiting,updated) and if I try to use those values it will throw an error:

    PS C:\Windows\system32> Get-SCSMIncident -status updated
    The provided enum value for IncidentStatus is invalid. For a list of valid values, type "Get-Help New-SCSMIncident".

    I also have question for Anders. When I run update.vbs from cmd I got this error:

    C:\Program Files (x86)\service_desk_script\update_incident_vb_script>cscript upd
    ate.vbs
    Microsoft (R) Windows Script Host Version 5.7
    Copyright (C) Microsoft Corporation. All rights reserved.

    C:\Program Files (x86)\service_desk_script\update_incident_vb_script\update.vbs(
    30, 5) Microsoft VBScript runtime error: Type mismatch: 'CLng'

     I have changed the "Contoso-IR" to "DD-IR" and the file path of update.ps1 file. I also changed the "Contoso-IR" string on handlemails script and it works fine (mails are separated to NewSCSM & updateSCSM). Any idea what could cause that error?

    Thanks both of you guys for helping and coding those script.

    -Mikko

    Thursday, June 17, 2010 2:30 PM
  • Ok here is what i had to do to get this working;

     

    Manually created the scripts, 

    set the execution policy to unrestricted

    edited the profile.ps1 to automatically add in the snap ins

    changed the ps1 script to only contain the following;

    Set-SCSMIncident -ID $args[0] -Comment $args[1] -AttachmentPath $args[2]

    write-host $args[0]

    write-host $args[1]

    write-host $args[2]


    and it work's without error

    I am running Outlook 2010, so i had to make some manual changes to the registry files as they are not the same for 2010 ans it uses the eml.14 extension


    Thanks Patrick, Anders scripts are great.

    Thursday, June 17, 2010 4:08 PM
  • Hi again guys!

    Good to here that you've been able to solve your issues!

    Regarding the cmdlets and custom enum/list values. You should actually be able to use your custom values by using the guid instead of the friendly name. To get hold of the guid you can run the query below on the Service Manager database. The guid we're looking for is listed as EnumTypeId in the search result.

    Select EnumType.EnumTypeId, LocalizedText.LTValue
    From EnumType INNER JOIN
    LocalizedText.LTValue ON EnumType.EnumTypeName = LocalizedText.ElementName
    Where LocalizedText.LTValue LIKE '%YourFriendlyName%'

    Let me know if it works for you!

    PS. Someday I'll add relevant doumentation to the cmdlets on codeplex. So much to do within a limited amount of time :)


    Patrik Sundqvist Solutions Architect @ Atea Spintop http://blogs.litware.se
    Thursday, June 17, 2010 8:12 PM
    Moderator
  • Msg 208, Level 16, State 1, Line 1
    Invalid object name 'LocalizedText.LTValue'.
    Thursday, June 17, 2010 8:29 PM
  • Ah, typo!

    Let's give this another try :)

    SELECT

     

    EnumType.EnumTypeId, LocalizedText.LTValue, EnumType.EnumTypeName, LocalizedText.LTStringType
    FROM EnumType INNER JOIN
    LocalizedText ON EnumType.EnumTypeName = LocalizedText.ElementName
    WHERE (LocalizedText.LTValue LIKE '%YourFriendlyName%')


    Patrik Sundqvist Solutions Architect @ Atea Spintop http://blogs.litware.se
    Friday, June 18, 2010 6:28 AM
    Moderator
  • Hello guys!

    Thanks Patrik, your query worked fine. Now I can use all of my custom statuses and trigger more specific email notifications. I also solved the another problem. Someone on Anders' blog explained it.

    Little notice about the update vbs (correct if I'm totally wrong). Some day you will reach the ID 1000 and the script stops working properly. It can handle at the moment only 3 number IDs. Adding one more "If CLng" will solve the problem.

    -Mikko

    Wednesday, June 23, 2010 8:25 AM
  • I'll be posting a new CodePlex project soon that will allow you to handle email replies with a direct connection to an Exchange mailbox via Exchange Web Services.  Watch the SCSM team blog for the announcement:

    http://blogs.technet.com/b/servicemanager


    Travis Wright Senior Program Manager Lead Microsoft
    Thursday, July 8, 2010 9:45 PM
  •  

    Anders/Patrick?

     

    Is there any logging we can add to these.

     

    Just had reports that attachements are getting attached to the wrong incidents, so would like to track / log for fault diagnosis

     

     

    Tuesday, July 13, 2010 3:13 PM
  • Hi,

    You can add anything you want to the scripts. There is not much logging today, but you can add lines that echo to a logfile if you want too.


    Anders Bengtsson | Microsoft MVP - Operations Manager | http://www.contoso.se
    • Proposed as answer by cdm2010 Friday, July 30, 2010 5:29 AM
    Sunday, July 25, 2010 10:40 AM
    Answerer
  • Hi Anders,

    Thank you for the scripts on updating incidents via email.

    I've setup this in my environment - the scripts all seems to run through successfully.  The "update" email in the "UpdateSCSM" folder gets deleted automatically eventually by the "update.vbs" script - but no information is being written back to the incident.

    I am running the scripts with my SCSMSA account which has full admin and was also used to setup the environment.

    Not sure if it is the powershell bit that fails - any recommendations welcome.

    Thanks,

    j.

     

    Thursday, September 9, 2010 9:12 AM
  • Try run the scripts manually with the same account, add a couple of "echos" for example in VB Wscript.Echo to get a popup about each parameter. It is useful to see what data the script is using, if it is really picking up the incident, what ID the incident has and so on. Always good for troubbleshooting.
    Anders Bengtsson | Microsoft MVP - Operations Manager | http://www.contoso.se
    Thursday, September 9, 2010 9:31 AM
    Answerer
  • has anyone else noticed that when the .eml file is attached to the incident being updated, that the time stamp is way off, in some cases showing that the attachment was added before the ticket was even opened?

    Is there a way to fix this, maybe somewhere in the database?

    Monday, December 20, 2010 8:48 PM
  • there was a post in this forum about that before:

    "Date Time" value in IR Action Log"

    [quote] from Anton Gricenko - FreemanRU

    Look like a bug in SMLets. They use DateTime.Now but must use DateTime.Now.ToUTC()

    [/quote]


    Andreas Baumgarten | H&D International Group
    Tuesday, December 21, 2010 7:15 AM
    Moderator
  • Thanks Andreas, I will run with that. Now my next issue with the update by email scripts, and maybe this is a bug, but I have an issue with seperate reply emails being attached to the wrong incidents.

    For example: I have two seperate incidents that I request user input for, they both reply back at the same time and therefore are processed through the scripts at the same time and when processed by the PS script they are both attached to the first incident that is read by the Powershell script. Is there a way to get each reply to attach to the correct incident?

    Tuesday, December 21, 2010 4:38 PM
  • Hi Guys,

     

    Im also having this problem, ive installed the smlets, changed the script to use "IncidentID: IR" for searching and im still having the problem, the eml files are moving from the drop folder to updatescsm and newscsm.  once in the updatescsm it stays there, this is the output i get:

    this is what is being run:

    *************************************************************************************************

    if (-not (Get-PSSnapin SMLets -ErrorAction SilentlyContinue))
     {Import-module SMLets}

    Set-SCSMIncident -ID $args[0] -Comment $args[1] -AttachmentPath $args[2]
    Write-host $args[0]
    Write-host $args[1]
    Write-host $args[2]

    *************************************************************************************************

    and this is what i get at the first run:

    *************************************************************************************************

    PS D:\emailscripts\emailscripts> D:\emailscripts\emailscripts\update.ps1
    Access to the path 'D:\emailscripts\emailscripts' is denied.
    At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\SMLets\SMLets.psm1:4 char:23
    + $GLOBAL:SMDIR    = "$D <<<< :\Program Files\Microsoft System Center\Service Manager 2010"
        + CategoryInfo          : PermissionDenied: (D:\emailscripts\emailscripts:String) [], UnauthorizedAccessException
        + FullyQualifiedErrorId : GetContentReaderUnauthorizedAccessError
     
    Access to the path 'D:\emailscripts\emailscripts' is denied.
    At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\SMLets\SMLets.psm1:5 char:23
    + $GLOBAL:SMSDKDIR = "$D <<<< :\Program Files\Microsoft System Center\Service Manager 2010\SDK Binaries"
        + CategoryInfo          : PermissionDenied: (D:\emailscripts\emailscripts:String) [], UnauthorizedAccessException
        + FullyQualifiedErrorId : GetContentReaderUnauthorizedAccessError
     
    Resolve-Path : Cannot find path 'D:\Microsoft.EnterpriseManagement.Core.dll' because it does not exist.
    At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\SMLets\SMLets.psm1:32 char:33
    +         $dllpath = (resolve-path <<<<  $dll).path
        + CategoryInfo          : ObjectNotFound: (D:\Microsoft.En...gement.Core.dll:String) [Resolve-Path], ItemNotFoundException
        + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.ResolvePathCommand
     
    Exception calling "LoadFile" with "1" argument(s): "The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))"
    At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\SMLets\SMLets.psm1:39 char:44
    +             [reflection.assembly]::LoadFile <<<< ($dllpath)
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : DotNetMethodException
     
    Set-SCSMIncident : Cannot validate argument on parameter 'ID'. The argument is null or empty. Supply an argument that is not null or empty and then try the command again.
    At D:\emailscripts\emailscripts\update.ps1:4 char:21
    + Set-SCSMIncident -ID <<<<  $args[0] -Comment $args[1] -AttachmentPath $args[2]
        + CategoryInfo          : InvalidData: (:) [Set-SCSMIncident], ParameterBindingValidationException
        + FullyQualifiedErrorId : ParameterArgumentValidationError,SMLets.SCSMIncidentSet
     
    *************************************************************************************************

    when I run it again I get:

    *************************************************************************************************

    PS D:\emailscripts\emailscripts> D:\emailscripts\emailscripts\update.ps1
    Set-SCSMIncident : Cannot validate argument on parameter 'ID'. The argument is null or empty. Supply an argument that is not null or empty and then try the command again.
    At D:\emailscripts\emailscripts\update.ps1:4 char:21
    + Set-SCSMIncident -ID <<<<  $args[0] -Comment $args[1] -AttachmentPath $args[2]
        + CategoryInfo          : InvalidData: (:) [Set-SCSMIncident], ParameterBindingValidationException
        + FullyQualifiedErrorId : ParameterArgumentValidationError,SMLets.SCSMIncidentSet
     

    *************************************************************************************************

     

    Any clues?? Need some help please....

     

    this is the full script:

    *****************************************************************************************************

    Set fso = CreateObject("Scripting.FileSystemObject")
    sFolder = "C:\Inetpub\mailroot\drop\UpdateSCSM"

    Set folder = fso.GetFolder(sFolder)
    Set files = folder.Files

    For each folderIdx In files

     Const ForReading = 1
     Set objRegEx = CreateObject("VBScript.RegExp")
     objRegEx.Pattern = "IncidentID: IR"
     Set objFSO = CreateObject("Scripting.FileSystemObject")
     Set objFile = objFSO.OpenTextFile(sFolder & "\" & folderIdx.Name, ForReading)

     Do Until varMatch > 0
      strSearchString = objFile.ReadLine
          Set colMatches = objRegEx.Execute(strSearchString) 
          If colMatches.Count > 0 Then
       varMatch = 2
              For Each strMatch in colMatches  
        varPosition = (InStr(strSearchString,"IncidentID: IR"))
        varNewPosition = varPosition + 8


        varNoFiguresPos = varPosition + 10
        varNoFigures = (Mid(strSearchString,varNoFiguresPos,1))
        If CLng(varNoFigures) Then
         varNoInt = 3
         varNoFigures = (Mid(strSearchString,varNoFiguresPos,2))
         If CLng(varNoFigures) Then
          varNoInt = 4
          varNoFigures = (Mid(strSearchString,varNoFiguresPos,3))
          If CLng(varNoFigures) Then
           varNoInt = 5
          End IF
         End If
        End If
        
        varIncident = (Mid(strSearchString,varNewPosition,varNoInt))  
               Next
          End If
     Loop

     sPath = sFolder & "\" & folderIdx.Name
     sData = "Update from end-user e-mail"
     pscommand = "D:\emailscripts\emailscripts\update.ps1" & " " & varIncident & " " & "'" & sData & "'" & " " & sPath
     Wscript.ECho pscommand
     cmd = "powershell.exe " & pscommand
     Set shell = createObject("Wscript.Shell")
     Set executor = shell.exec(cmd)
     executor.StdIn.Close

    Do While Executor.Status <> 1   
     WScript.Sleep 100
    Loop

     

    objFile.Close
    Set fso = CreateObject("Scripting.FileSystemObject")
    fso.DeleteFile sPath, True


    Next

    ***************************************************************************************************************************

     

    I would be very greatful for any help on this.  Thanks

    Amarpal

    Wednesday, January 5, 2011 6:10 PM
  • Hi

    Just some things to check.

    Access to the path 'D:\emailscripts\emailscripts' is denied.
    Does the executing account have access to the path?

    For some reason the import methog is looking for the "Core" assembly in the following path: 'D:\Microsoft.EnterpriseManagement.Core.dll'
    Does it exist there or is it looking in the wrong place? :)


    Patrik Sundqvist Solutions Architect @ GridPro AB Blog: http://blogs.litware.se
    Wednesday, January 5, 2011 6:43 PM
    Moderator
  • Hi Patrick,

     

    Thats for your reply and sorry for my late one,  d:\emailscripts\emailscripts is open to everyone, so now I have the problem that when an email comes in to scsm server it goes to the drop box, then the handle script sorts the email if its a one it'll go to newscsm, if its a reply it will go to updatescsm folder.  scsm looks to newscsm folder and opens an incident, however if there is a an eml in the updatescsm folder the update script runs and the eml file from updatescsm disappears and doesnt attach it self to any incident in scsm??? any clues?

     

    Thanks

    Amarpal

    Thursday, January 13, 2011 4:25 PM
  • Hi Anders,

     

    Im having the same issue as Johan, im not much of a scipting guy and would appriciate the help, both scripts run, but when the update script runs, the eml file dissappears from the updatescsm folder and i dont know where it goes??

     

    Thanks

    Amarpal

    Thursday, January 13, 2011 4:32 PM
  • anyone??
    Monday, January 17, 2011 2:58 PM
  • If your goal is just to update incidents via email, I would recomend using the Service Manager - Exchange connector instead.

    http://blogs.technet.com/b/servicemanager/archive/2011/01/07/exchange-connector-released.aspx 


    Travis Wright Senior Program Manager Microsoft
    Monday, January 24, 2011 10:52 PM
  • Hi Travis,

     

    Thanks for that.  Now im have a few problems with the Exchange connector it finishes with errors and im not sure what the problem is:  ive posted on this thread:

     

    http://social.technet.microsoft.com/Forums/en-US/administration/thread/b253c8e1-d9aa-41db-aab1-9051b2e6381e?prof=required

     

    Thanks

    Amarpal


    Amarpal Attwal IT Consultant | Venture 1 Consulting
    Tuesday, January 25, 2011 10:22 AM