Showing posts with label SCSM. Show all posts
Showing posts with label SCSM. Show all posts

Wednesday, September 3, 2014

Tip: Approve all In Progress Activities in Service Manager

Stop manually approving each test review activity. Service Manager implementations usually include immense amounts of testing. If you are testing Service Requests or Change Requests, you probably have tons of review activities to approve. It can be time consuming to approve each activity, because, unlike manual activities, we can't just select them all and complete them. We have the option of deleting or canceling the work items, but this isn't really testing.

SMLETS and powershell makes our lives much easier when it comes to administration. However, review activity relationships are slightly different than most other relationships. It can sometimes be difficult to figure out what to do when it comes to powershell and reviewers.

The below powershell script retrieves all review activities, retrieves the reviewers for those activities, and then sets the decision to approved. This will allow the review activity to review the decisions, and then complete itself - exactly as it would happen inside the console.

If you don't care how it works, then just grab the script and run it on your management server where you have SMLETS installed.
If you want to learn a little and become a better Service Manager Administrator, I have broken down the script.
If you don't have SMLETS, you can get it from Codeplex.

The script with explanation comments:
#This is pretty self-explanatory, but we are importing SMLETS.
Import-Module SMLETS
#Before we can retrieve any objects, we need to get the object class. The Object class we are looking for is "ReviewActivity". Why the "$" (dollar sign) at the end? As part of this particular cmdlet,  the search is using regexp. The "$" marks the end of the line. We use this because there are cases where the cmdlet would retrieve more than one object class due to regexp matching.
$RAC = get-SCSMClass System.WorkItem.Activity.ReviewActivity$
#We need to filter out object results to only "In Progress" review activities. "Activity Status" is an enumeration.
$ActStatusEnumInProgress = Get-SCSMEnumeration ActivityStatusEnum.Active$
#We need the GUID of the enumeration so our "filter" switch will retrieve the correct results.
$InProgressEnumId = $ActStatusEnumInProgress.id
#Here, we are querying the review activity objects. The "class" switch specifies what class we want, in this case, "review activity".
#The "Filter" switch is a server side filter that is far more efficient than "Where-object". We can filter on any column for that object.
$RAS = get-SCSMObject -class $RAC -filter "Status -eq '$InProgressEnumId'"
#So far, we should have all of the Review activities that are in progress. You can type $RAS to see a list of the review activities.
#We probably have more than one activity in an array, but we need to perform actions on each individual object. 
foreach ($RA in $RAS){
  #We are going to retrieve any relationships for each activity, where the activity is the source of the relationship.
  $RElObj = Get-SCSMRelationshipObject -BySource $RA
  #We do not want all relationships, only the reviewer relationship.
  foreach ($Obj in $RELObj) {
    if ($Obj.TargetObject.ClassName -eq "System.Reviewer") {
      #Now we are getting the reviewer object itself, but rather than specifying class and filter, we have the GUID. We can use the "id" switch.
      #Once we get the object, we are piping the object into the "Set-SCSMObject" command, which will update the object. The only thing we have to do is set the status to approved for each of the reviewers and internal SCSM workflow will take care of the rest.
      #The command below will not actually make any changes. The "whatif" switch is a powershell switch that essentially tells you what the command is going to do, but does not commit the command. This is a great way to test non-destrutively.
      #Many commands perform actions without output, so it is sometimes difficult to see what is going on. The "verbose" switch will output additional details at command execution.
      #If you are ready to execute the command and approve your activities, simply remove "-whatif".
      get-SCSMObject -id ($Obj.Targetobject.ID) | Set-SCSMObject -Property Decision -Value "Approved" -whatif -verbose
    }
  }
}

The Script with no comments:
Import-Module SMLETS
$RAC = get-SCSMClass System.WorkItem.Activity.ReviewActivity$
$ActStatusEnumInProgress = Get-SCSMEnumeration ActivityStatusEnum.Active$
$InProgressEnumId = $ActStatusEnumInProgress.id
$RAS = get-SCSMObject -class $RAC -filter "Status -eq '$InProgressEnumId'"
foreach ($RA in $RAS){
  $RElObj = Get-SCSMRelationshipObject -BySource $RA
  foreach ($Obj in $RELObj) {
    if ($Obj.TargetObject.ClassName -eq "System.Reviewer") {
      get-SCSMObject -id ($Obj.Targetobject.ID) | Set-SCSMObject -Property Decision -Value "Approved" -whatif -verbose
    }
  }
}

When you begin writing powershell scripts, it is a good idea to keep them in a repository, as you will most likely need them more than once, especially when it comes to System Center. If you want to talk more about powershell or System Center, come see me at Techfest Saturday, September 13th at the Sparkhound booth!
Techfest Registration: Techfest Registration
Techfest Site: Houston Techfest

Wednesday, December 29, 2010

Workflow Performance - Management Packs on the media to help Performance

Workflow Performance

Workflows are automatic processes that occur and include sending e-mail notifications, the next step of a change request activating, and automatically applying a template.
  • Normally, workflows start and finish within 1 minute. When Service Manager server roles are under a heavy workload, workflows do not complete as quickly as normal.
  • Additionally, when you create new workflows, such as a new notification subscription, additional load is placed on the system. As the number of new workflows that you create increases, the time it takes for each one to run also increases.
When the system is under a heavy load, if for example a large number of new incidents are being created and each incident generates many workflows, then performance might be negatively affected.
If you plan to create a large number of workflows, one possible solution to help improve performance is to use the ManagmentHostKeepAlive management pack that is included in the Service Manager release media.
  • You need to manually copy the two files from the source directory into the Service Manager installation directory, and then import the management pack files.
  • Importing these management pack files can greatly increase workflow processing responsiveness where almost all workflows process within 1 minute.
  • However, importing this management pack gives higher priority to workflow processing and can lead to slower Service Manager console response in some cases so you should test its impact before deployment in a production environment.

Monday, November 22, 2010

Troubleshooting Operations Manager Alert Connector

In Service Manager, there have been times where the OpsMgr Alert connector would stop forwarding alerts. I would troubleshoot for hours to no end. I tried just about everything short of uninstalling the software. Finally, I found what seems like a tried and true solution (for me).

Operations Manager Alert Connector problems I have had:

  • Alerts stop forwarding
  • I received a "Task Cannot be completed" error when attempting to delete the connector in SM, or even trying to view the properties.
Here are the steps I took to get alert forwarding working again. 

***Disclaimer: Microsoft may not support all of these steps, so please test and use at your own risk.

Delete the SCSM Connector
  • Open SCSM
  • Go to the Administration Tab, then go to connectors
  • Find the OpsMgr Alert Connector and delete it.
What if it won't delete?
  • I have been searching for a way to delete it from the database, but I have not been successful. I will update this post when I do.
Delete the Connector from OpsMgr
Create a new Connector in Service Manager (Pulled Directly from the Admin Guide)
***Follow steps exactly, and wait for the Connector to show up in Operations Manager
1.   In the Service Manager console, click Administration.
2.   In the Administration pane, expand Administration, and then click Connectors.
3.   In the Tasks pane, under Connectors, click Create Connector, and then click Operations Manager Alert Connector.
4.   Follow these steps to complete the Operations Manager Alert Connector Wizard:
a.   On the Before You Begin page, click Next.
b.   On the General page, in the Name box, type a name for the new connector. Make sure that the Enable check box is selected, and then click Next. Make note of this name; you will need this name in step 7 of this procedure.
c.   On the Server Details page, in the Server name box, type the name of the server that is hosting the Operations Manager root management server. Under Credentials, click New.
d.   In the Run As Account dialog box, in the Display name box, type a name for this Run As account. In the Account list, select Windows Account.
e.   In the User Name, Password, and Domain fields, type the credentials for the Run As account, and then click OK. For more information about the permissions that are required for this Run As account, see Accounts Required During Setup (http://go.microsoft.com/fwlink/?LinkId=182907) in the System Center Service Manager Planning Guide.
f.    On the Server Details page, click Test Connection. If you receive the following confirmation message, click OK, and then click Next:
The connection to the server was successful.
g.   On the Alert Routing Rules page, click Add.
h.   In the Add Alert Routing Rule dialog box, create a name for the rule, select the template that you want to use to process incidents created by an alert, and then select the alert criteria you want to use. Click OK, and then click Next.
i.    On the Schedule page, select Close alerts in Operations Manager when incidents are resolved or closed or Resolve incidents automatically when the alerts in Operations Manager are closed, click Next, and then click Create.
5.   Start the Operations Manager console, and connect to the Operations Manager root management server.
6.   Use the appropriate method based on the version of Operations Manager 2007 you are using:
·      In Operations Manager 2007 SP1, in the Administration pane, click Product Connectors.
·      In Operations Manager 2007 R2, in the Administration pane, click Product Connectors, and then click Internal Connectors.
7.   In the Connectors pane, click the name of the alert connector you specified in step 4b.
8.   In the Actions pane, click Properties.
9.   In the Alert Sync: <name of connector> dialog box, click Add.
10.  In the Product Connector Subscription Wizard dialog box, on the General page, in the Subscription Name box, type the name for this subscription. For example, type All Alerts, and then click Next.
11.  On the Approve groups page, click Next.
12.  On the Approve targets page, click Next.
13.  On the Criteria page, click Create.
14.  In the Alert Sync:<name of connector> dialog box, click OK.
To validate the creation of an Operations Manager 2007 alert connector
·      Confirm that the connector you created is displayed in the Service Manager console in the Connectors pane.
·      Confirm that incidents are created in Service Manager from alerts in Operations Manager.

New System Center Service Manager Blog

I have recently been required to learn, demo and deploy Service Manager to various customers. I have created this blog to help you and me in our journey with System Center Service Manager. Feel free to comment on posts, as I will probably need help along the way. I will attempt to post the more helpful articles.