Posts Tagged ‘Assigned to user’

So one of the biggest issues I have with Service Manager is actually user based as seems to be quite difficult to teach the concept of this for some strange reason. So, as a work-around I have created views that cater for the issue I am about to discuss.

The issue is as follows, when a Work Item gets re-assigned to a new Analyst, 99% of the time, the associated Support Group does NOT get changed. Let’s take the following example.

An incident is logged and is automatically assigned to the “Service Desk” team, now an analysts investigates the incident and determines that the incident actually belongs to a member of the “Network Team”. So, typically, the “Assigned to” person is changed and the new analyst will get an e-mail stating that a call has been assigned to him/her. However, the incident now reflects the following

Analyst : Network Analyst Thumbs up

Support Group : Service Desk Thumbs down

So basically, if you were to have a queue or view that shows up all incidents assigned to the “Network Team”, this incident would not show up however the analyst has received and e-mail stating that an Incident has been assigned to him/her, it can of course be found by using “Assigned to Me” View.

There is a solution here. Enter Cireson and their fantastic applications for Service Manager. SCSM Group Assign allows the extended functionality of selecting the required Support Group and then NARROWS the list of Analysts to that specific group. This ensures that BOTH the Support Group and Analyst are changed at time of re-assignment, making the creation of views and Queues a lot simpler and then ensures that your views based on Support Group are 100% accurate. The solution extends the context pane and adds a “Assign Analyst by Group” option

image

What SCSM Group Assign allows you to is the following (this is my test lab), you will however get the idea.

Below is a screenshot of the groups that I have created within Active Directory to “illustrate” my different Support Groups. You will see a few groups.

1. For all analysts

2. To represent different support Groups (I have called them Tier 1,2 and 3, as this is the vanilla experience with SCSM)

image015

Ok, so below is a screenshot of a re-assignment using the new “Assign Analyst by Group” option. For this example I have used “Tier 1”. Note how the “Analyst” selection is limited to only 2 Analysts as per my groups earlier. Namely Analyst 1 and Analyst 2.

Tier1-group assign

The next screenshot depicts the same process only to “Tier 2” this time. This time the selection is limited to Analyst 3 and Analyst 4.

Tier2-group assign

The re-assignment is logged in Service Manager in the exact same way as any analyst assignment. This is an extension of the capabilities of Service Manager.

I would highly recommend SCSM Group Assign for any Service Manager installation.

scsmlogo25

image_thumb_thumb

Follow me.

facebook-small322252222twitter-small322252222

MCC11_Logo_Horizontal_2-color_thumb_

So recently I got an e-mail to my newly setup e-mail address, for just this reason Smile,  from someone asking if I knew a way to do the following.

image_thumb

“I was trying to find a way to find all Incidents related to a specific person (assigned  to or affected user) using PowerShell”

So, I decided the best to answer this with a blog post as maybe there are other people out there asking the same question. This is a quick solution using

get-scsmincident

At this moment in time, this will address ONLY incidents. I will work on some code using

get-scsmobject

to reference work items. I will add the pieces of code as I go and explain the code.

First lets start by importing the required module, SMLets can be downloaded here

import-module smlets

I am running these commands on a computer that is NOT the Management Server. So I need to specify a computer name when I am running these commands. So, in the next line I create a

$computername

variable to make my life easier. If you are running these commands on the Management Server, you can remove the

-computername $computername

piece of code. Below is how I created this, please use the name of your Management Server

$computername = “name of your Management Server"

Ok, so now lets get all active incidents. I will run a PowerShell Command to get all Incidents that are NOT EQUAL to “Resolved” or “Closed”. This allows us to cover all other incident statuses you may have created. Notice the –ne operator.

$allincidents = Get-SCSMIncident -ComputerName $computername | Where-Object {$_.Status -ne "resolved" -and $_.status -ne "closed"}

So now we have all the incidents in an object, now what????

Personally, I choose to sort the information, enter

Sort-Object

with Powershell. So, to elaborate a little further you can use

get-member

orGM” for short and “pipe” your variable to “GM” / Get-member

$allincidents | gm 

OR

$allincidents | get-member 

image

Now you have a list of all the properties you can use. You can also go deeper into the ‘Members’ of the object. You can do the following as well

$allincidents.affecteduser | gm 

It is simply a case of playing around and digging a little bit.

So now back to the

Sort-Object

. I wanted to sort by AssignedTo user, this can be easily changed by changing the

-Property 

field of the

sort-object 

I also chose for this example to display the information in a useful grid. This too can be changed as needed.

$allincidents | Sort-Object -Property Assignedto | Select-Object -Property ID, Displayname, AffectedUser, Assignedto | Out-GridView

You will get some results like the below.

image

You can also limit the results by “Assigned To” user like such using either

-like 

or

-eq 

operators. Examples below

-like operator. The example is finding all calls assigned to a user where the name is like “Kok*”. This time without the “out-gridview”

$allincidents | Where-Object {$_.assignedto.displayname -like "kok*"} 

image

-eq operator. This example finds all incidents assigned to a user with a specific name. In my example I am using “Desmond Hilton”

$allincidents | Where-Object {$_.assignedto.displayname -eq "Desmond Hilton"}

image

The PowerShell code can be easily adapted to meet the requirements for the “Affected User”. We simply change the value to use with the current object like such. I use

$Get-member

on “Affecteduser”

$allincidents.affecteduser|gm

. Again you can use the

-like 

or

-eq 

operators

$allincidents | Where-Object {$_.assignedto.displayname -like "kok*"} 

-like operator. In this example I am using the Name “like” Roland

$allincidents | Where-Object {$_.affecteduser.DisplayName -like "Roland*"}

image

-eq operator. In this example I am using the “Affected User” name of “Andre Botes”

$allincidents | Where-Object {$_.affecteduser.DisplayName -eq "andre Botes"}

image

This should help you to make more in-depth queries and enjoy using PowerShell and SMLets to get valuable information from System Center Service Manager.

I have also setup an new e-mail address to help with Service Manger queries. you can e-mail me at systemcenterguyza ”at” live ”dot” com  (systemcenterguyza@live.com) and I will assist as much as I can.

I have also setup a new Twitter account to focus the Information around the System Center Suite.

scsmlogo2

image_thumb

Follow me.

facebook-small322252222twitter-small322252222

MCC11_Logo_Horizontal_2-color_thumb_

Just recently I was looking for a way to notify users about Inactive incidents as I have some departments that tend to ignore their work items and an e-mail about their “untouched” incidents seems to motivate them. So after some searching I found this script from Andreas Baumgarten

Please note : I only modified this script to extend its use to other Statuses to be monitored. All credit for the script goes entirely to Andreas Baumgarten

Code is below

# Configure Last Modified Days Before
$ModifiedBefore = 3

#Configure Incident Status
$IncidentStatus = 'Active'

# Configure your mail server, the recipient and the sender of the mail
# $smtphost=”mailserver.yourdomain.local”
# $from=”mail@yourdomain.local”

$smtphost=”Mailserver.demo.local”
$from=”Helpdesk@demo.local”

# Send-Mail function
function Send-Mail
{
Param($From,$To,$Subject,$Body)
$smtp = new-object system.net.mail.smtpClient($smtphost)
$mail = new-object System.Net.Mail.MailMessage
$mail.from= $From
$mail.to.add($To)
$mail.subject= $Subject
$mail.body= $Body
$mail.isbodyhtml=$true
$smtp.send($Mail)
}

# Some other variables
$BeforeDate = (Get-Date).AddDays(-$ModifiedBefore).ToString("MM/dd/yyy HH:mm:ss")
$Status = Get-SCSMEnumeration IncidentStatusEnum.$IncidentStatus$
$AssignedUserObjectRelClass = Get-SCSMRelationshipClass System.WorkItemAssignedToUser
$IncidentClass = Get-SCSMClass -name System.WorkItem.Incident$

#Get all incidents last modfied xy days before
$Incidents= @(Get-SCSMObject -Class $IncidentClass | Where {($_.Status -eq $Status -AND $_.LastModified -lt $BeforeDate)})

If ($Incidents.count -gt 0)
{

#Get all assigned incidents from list
foreach ($Incident in $Incidents)
{
# Get AssignedToUser
$AssignedUser = Get-SCSMRelatedObject -SMObject $Incident -Relationship $AssignedUserObjectRelClass

# Incidents AssignedTo is not NULL
If ($AssignedUser.Displayname -ne $NULL)
{
#Get email adress of AssignedToUser
$EndPoint = Get-SCSMRelatedObject -SMObject $assignedUser -Relationship $UserPref|?{$_.ChannelName -like '*SMTP'}
$Sendto = $Endpoint.Targetaddress

#Create Output
$Output = 'This Incident has been inactive for ' + $ModifiedBefore + ' day(s): <br>' + $Incident.ID + ' - ' + $Incident.Title + ' - Last Modified: ' + $Incident.Lastmodified
$Output
#Send email
$To = $Sendto
$Subject = 'Inactive incident for ' + $ModifiedBefore + ' day(s): ' + $Incident.Id + ' ' + $Incident.Title
$Body = $Output
Send-Mail $From $to $Subject $Body
}
}
}

Remove-Module SMlets -force 

Okay, so now that the code is there, I had to make some modifications in order for the Code to work with “NON-DEFAULT” Incident Statuses. I have created some additional Pending statuses.

The key line in this code is

Configure Incident Status
$IncidentStatus = 'Active'

and

$Status = Get-SCSMEnumeration IncidentStatusEnum.$IncidentStatus$

This allows you specify the Status. However if you use additional “NON-DEFAULT” statuses, this would need to be modified to suit your needs. You would need to modify the line of code to read as follows.

$IncidentStatus = 'Enum.847741a452db4d529741005ea73aead8'

and

$Status = Get-SCSMEnumeration $IncidentStatus$

You will notice the change of $IncidentStatus to a “ENUM” Value as this is a “NON-DEFAULT” value, you need to use the ENUM value. This can be gotten by using the following with SMLets

Get-SCSMEnumeration | Format-list | out-file

Below, is a screenshot to help illustrate this further.

EnumSearch1

Once you have a list of all your Enumerations, then search for the required value, for example “Pending – Waiting for 3rd Party”, you will then see a “Name” value and that whole string is your ENUM value.

You will also see that the $Status line has been changed to cater for the ENUM value.

Modify to meet your needs and create a workflow if you want to.

Follow me.

facebook-small322252222twitter-small322252222

MCC11_Logo_Horizontal_2-color_thumb_