Home Cireson Uploads

PowerShell Version of Action Log Notify

Geoff_RossGeoff_Ross Cireson Consultant Super IT Monkey ✭✭✭✭✭
edited December 2016 in Cireson Uploads
Hey,

Anyone else find that Action Log Notify can be a bit frustrating to configure especially when you want to try and do something clever like use a different email template depending on the Work Item type.

Here's a PowerShell based version which gives you super flexibility. I've chucked in a sample HTML email template but insert your own to match the rest of your notifications.

You can trigger it in any Automation platform, Orchestrator is nice and easy as it provides an OOB activity to Monitor for new Comments. You can set your runbook up like this.



And configure the Monitor Object like this



Don't forget to include the filter to only trigger on Non-Private comments!!!

Then add the attached PowerShell into the Run .Net Script and link the two by passing in the SCObjectGuid of the Comment into the first line of the PowerShell.

Hope you like this and find it helpful. Please post some examples of the cool html emails I know you guys will create for this.

Geoff

Comments

  • seth_coussensseth_coussens Member Ninja IT Monkey ✭✭✭✭
    Just a heads up, this is a great powershell example of what can be done. 

    On the other side, in the near future you should see action log notify incorporated into Notify Analyst to make configuration easier, and streamline the experience.

    Until then, great work Geoff!
  • Leigh_KildayLeigh_Kilday Member Ninja IT Monkey ✭✭✭✭
    Nice one, Geoff!

    How would you go about setting up a monitor for Support Group changes? Notify Analyst doesn't work for us because we're running on multiple domains and members cannot be enumerated. Moving this to PowerShell may be the answer.

    We have a script to check the last history entry of a WI to determine whether a field changed, but we'd still need to run a monitor on New or Updated SRs, which is horribly inefficient.
  • Dennis_de_JagerDennis_de_Jager Customer IT Monkey ✭
    Hi Geoff,

    Great work! Just a heads up, in your text you mention:
    Don't forget to include the filter to only trigger on Private comments!!!

    But I think you try to mention to only trigger on non-Private comments.

    I think everybody understands what you mean, but you aren't stating it.



    I'm going to try this soon, any indication when we can expect an update of the Notify Analyst product?

  • Geoff_RossGeoff_Ross Cireson Consultant Super IT Monkey ✭✭✭✭✭
    Thanks, Dennis, that would be a fairly bad mistake to set it up like that. Oops. Edited.
  • David_JohnsenDavid_Johnsen Customer Advanced IT Monkey ✭✭✭
    @Geoff_Ross, I've tweaked your powershell a little, but now I'm getting the following error:

    The term 'Get-SCSMObject' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

    Is it something I've edited wrong, or do I need to do something extra?
  • seth_coussensseth_coussens Member Ninja IT Monkey ✭✭✭✭
    @Geoff_Ross, I've tweaked your powershell a little, but now I'm getting the following error:

    The term 'Get-SCSMObject' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

    Is it something I've edited wrong, or do I need to do something extra?
    In Geoff's powershell he isn't explicitly loading the SMLets. You'll needt o load those prior to running (or at the top of the script) in order for this to work properly. He is assuming they are globably imported in his script which is common in a lot of Orchestrator environments where SCSM is the primary use for Orchestrator.
  • David_JohnsenDavid_Johnsen Customer Advanced IT Monkey ✭✭✭
    Ah right, sorry new to powershell!

    I've loaded smlets now and set the SM Computer, but I'm still getting an error "The Data Access service is either not running or not yet initialized. Check the event log for more information."

    Is there a simple way to call the default PS connection in a runbook? As there seems to have been one configured in our environment (by previous colleagues)
  • seth_coussensseth_coussens Member Ninja IT Monkey ✭✭✭✭
    If you just load the module but it isn't on a management server (in this case you'd need the management server installed on the SCOR box, we do this often) you can use the -computer <servername> argument of each SMLet command to direct the command to run on a service manager management server.
  • David_JohnsenDavid_Johnsen Customer Advanced IT Monkey ✭✭✭
    Sorry this was a silly mistake by me! 
    I had researched about the -computername and was instead using the command:
    $SMDefaultComputer = "SCSMservename.domain.uk"

    But I had that above the Import-module!

    Getting there now!

  • seth_coussensseth_coussens Member Ninja IT Monkey ✭✭✭✭
    Great let us know if you have any other questions!
  • David_JohnsenDavid_Johnsen Customer Advanced IT Monkey ✭✭✭
    We're up and running!

    Attached a tweaked version of @Geoff_Ross 's script to Notify Assigned To Analyst, when a call is updated by another analyst - related to this post: https://community.cireson.com/discussion/comment/5559

    I've not included any filters on the comment visibility on my runbook as it's for Analysts so will need private and visible alerts.

    This is purely for reference, I'm new to PowerShell, so no guarantees regarding any of the outcomes!

  • fe_fefe_fe Customer IT Monkey ✭
    @David_Johnsen @Geoff_Ross
    I've been trying to do this with the SR actionlog and IR actionlog.
    Is Trouble Ticket Analyst Comment also what is used for Service Requests as actionlog, even though it's called Trouble Ticket?
  • David_JohnsenDavid_Johnsen Customer Advanced IT Monkey ✭✭✭

    @fe_fe Yes it works for both.

    I'm having a small issue with mine, where every so often it can't load the SMLets module. It errors with the below, and after a few hours and several failures it just starts working again!

    The module to process 'SMLets.psm1', listed in field 'ModuleToProcess' of module manifest 'C:\Common Files\SMLets\SMLets.psd1' was not processed because no valid module was found in any module directory.

    I have referenced the module directly in my script now, with "Import-module "C:\Common Files\SMLets" -Force" but it still fails.


    Any tips anyone? I suspect it may just be our environment, but any clues would be helpful.

    Thanks.

  • fe_fefe_fe Customer IT Monkey ✭
    @David_Johnsen
    Is it from Orchestrator?
    I've never had any issues like that.
    Have you installed SMLets properly on your Orchestrator Runbook server?
    http://cireson.com/blog/installing-smlets-on-system-center-orchestrator-2012-server-without-a-management-server/
  • David_JohnsenDavid_Johnsen Customer Advanced IT Monkey ✭✭✭

    Hi @fe_fe

    Yes it's Orchestrator, I fully expect its an issue with how it's installed as you've sent through. I'll keep my eye on it as it is very infrequent. There may be some sort of pattern.

    Thanks for your advice.

  • Peter_NordqvistPeter_Nordqvist Customer Adept IT Monkey ✭✭
    Just a heads up, this is a great powershell example of what can be done. 

    On the other side, in the near future you should see action log notify incorporated into Notify Analyst to make configuration easier, and streamline the experience.

    Until then, great work Geoff!
    @seth_coussens
    When is the near future? :)

  • Tom_HendricksTom_Hendricks Customer Super IT Monkey ✭✭✭✭✭
    Peter_Nordqvist said:
    @seth_coussens
    When is the near future? :)

    Please say "the future is now"....  It is a great decision for the product. 
  • Peter_MiklianPeter_Miklian Customer Advanced IT Monkey ✭✭✭

    @Leigh_Kilday for Support group change we use 2 runbooks monitoring SR/IR updates which call another runbook handling the actual change. What's wrong with this? Did you manage to create a better solution for support group changes? Thanks.


Sign In or Register to comment.