Using New-SCSMIncident to add support group (nested) e.g. ABC\1LS

Jan 23, 2013 at 3:41 PM

With very little powershell knowledge I managed to bodge a little app together that created, resolved and closed incidents for my service desk staff.

They basically put an end user name in and click on a button that refers to the problem for stuff service desk people do on the fly, e.g. username click changed password.

Anyway....

Its been quite popular and a few other teams where I work want to use it too, I have an issue though that their support groups are nested

e.g.

dept1\

dept1\1LS

dept1\2LS

I had a unique name for my dept so this wasn't an issue, New-SCSMIncident .......

with

–SupportGroup "ICT"

was fine, but it won't accept

–SupportGroup "dept1\2LS"

it would accept "2LS" but this could be any 1 of 4 departments.

Any ideas? could I somehow use the full enumeration string?

thanks

Paul Wilson

Jan 23, 2013 at 4:14 PM
Edited Jan 23, 2013 at 4:23 PM

Have you tried getting the child support group first?  It would look something like this (note that example is for incidents):

$supportgroup = get-scsmchildenumeration -enumeration (get-scsmenumeration -name tierqueue | where {$_.displayname -eq 'dept1'}) | where {$_.displayname -eq '2LS'}

Then insert $supportgroup in place of "depts1\2LS" in your above example.

Or you should just be able to set the -supportgroup switch to "(get-scsmchildenumeration -enumeration (get-scsmenumeration -name tierqueue | where {$_.displayname -eq 'dept1'}) | where {$_.displayname -eq '2LS'})" (without quotes).

I haven't tried this, but hopefully that would work.

Jan 25, 2013 at 12:38 PM

The first option worked a treat, thanks very much

Sep 14, 2013 at 1:39 PM
How did you create the app from a powershell script?
Did you create a UI?

u0005293 wrote:
With very little powershell knowledge I managed to bodge a little app together that created, resolved and closed incidents for my service desk staff. They basically put an end user name in and click on a button that refers to the problem for stuff service desk people do on the fly, e.g. username click changed password. Anyway.... Its been quite popular and a few other teams where I work want to use it too, I have an issue though that their support groups are nested e.g. dept1\ dept1\1LS dept1\2LS I had a unique name for my dept so this wasn't an issue, New-SCSMIncident ....... with –SupportGroup "ICT" was fine, but it won't accept –SupportGroup "dept1\2LS" it would accept "2LS" but this could be any 1 of 4 departments. Any ideas? could I somehow use the full enumeration string? thanks Paul Wilson
Sep 14, 2013 at 1:53 PM
Edited Sep 14, 2013 at 1:57 PM
``` my code below for the UI, I've since found a couple of utilities that would have created this for me, its a bit repetative and I could have used a function for a button and passed things in but I wanted someone else to be able to edit later and some of the incidents that relate to the buttons might be changes or tasks when SCSM is properly implemented.
Function MyMenu {

[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") 
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") 

$x=""
$y=""
$usrin=""

$objForm = New-Object System.Windows.Forms.Form 
$objForm.Text = "Log Quick Job"
$objForm.Size = New-Object System.Drawing.Size(310,300) 
$objForm.StartPosition = "CenterScreen"

$objForm.KeyPreview = $True
$objForm.Add_KeyDown({if ($_.KeyCode -eq "Enter") 
    {$x=$objTextBox.Text;$objForm.Close()}})
$objForm.Add_KeyDown({if ($_.KeyCode -eq "Escape") 
    {$objForm.Close()}})





#Change Pword
$PwordButton = New-Object System.Windows.Forms.Button
$PwordButton.Location = New-Object System.Drawing.Size(1,120)
$PwordButton.Size = New-Object System.Drawing.Size(75,23)
$PwordButton.Text = "Password"
$PwordButton.Add_Click({$x=$objTextBox.Text; $y="Changed User Password"; $source=$objTextBox3.Text; $objForm.Close()})
$objForm.Controls.Add($PwordButton)

#Chioce1
$c1Button = New-Object System.Windows.Forms.Button
$c1Button.Location = New-Object System.Drawing.Size(1,144)
$c1Button.Size = New-Object System.Drawing.Size(75,23)
$c1Button.Text = "AcLockd"
$c1Button.Add_Click({$x=$objTextBox.Text; $y="choice1"; $source=$objTextBox3.Text;  $objForm.Close()})
$objForm.Controls.Add($c1Button)

#Chioce2
$C2Button = New-Object System.Windows.Forms.Button
$C2Button.Location = New-Object System.Drawing.Size(1,168)
$C2Button.Size = New-Object System.Drawing.Size(75,23)
$C2Button.Text = "Asoc Amnd"
$C2Button.Add_Click({$y="choice2"; $x=$objTextBox.Text; $usrin=$objTextBox2.Text; $source=$objTextBox3.Text;  $objForm.Close()})
$objForm.Controls.Add($C2Button)

#Chioce3
$C3Button = New-Object System.Windows.Forms.Button
$C3Button.Location = New-Object System.Drawing.Size(1,192)
$C3Button.Size = New-Object System.Drawing.Size(75,23)
$C3Button.Text = "Query"
$C3Button.Add_Click({$y="choice3"; $x=$objTextBox.Text; $usrin=$objTextBox2.Text; $source=$objTextBox3.Text;  $objForm.Close()})
$objForm.Controls.Add($C3Button)

#choice2.1
$CH21Button = New-Object System.Windows.Forms.Button
$CH21Button.Location = New-Object System.Drawing.Size(100,120)
$CH21Button.Size = New-Object System.Drawing.Size(75,23)
$CH21Button.Text = "MyPr Paper"
$CH21Button.Add_Click({$y="choice21"; $x=$objTextBox.Text; $usrin=$objTextBox2.Text; $source=$objTextBox3.Text;  $objForm.Close()})
$objForm.Controls.Add($CH21Button)

#choice2.2
$CH22Button = New-Object System.Windows.Forms.Button
$CH22Button.Location = New-Object System.Drawing.Size(100,144)
$CH22Button.Size = New-Object System.Drawing.Size(75,23)
$CH22Button.Text = "MyPr Toner"
$CH22Button.Add_Click({$y="choice22"; $x=$objTextBox.Text; $usrin=$objTextBox2.Text; $source=$objTextBox3.Text;  $objForm.Close()})
$objForm.Controls.Add($CH22Button)

#choice2.3
$CH23Button = New-Object System.Windows.Forms.Button
$CH23Button.Location = New-Object System.Drawing.Size(100,168)
$CH23Button.Size = New-Object System.Drawing.Size(75,23)
$CH23Button.Text = "S Phone"
$CH23Button.Add_Click({$y="choice23"; $x=$objTextBox.Text; $usrin=$objTextBox2.Text; $source=$objTextBox3.Text;  $objForm.Close()})
$objForm.Controls.Add($CH23Button)

#choice2.4
$CH24Button = New-Object System.Windows.Forms.Button
$CH24Button.Location = New-Object System.Drawing.Size(100,192)
$CH24Button.Size = New-Object System.Drawing.Size(75,23)
$CH24Button.Text = "Eduroam"
$CH24Button.Add_Click({$y="choice24"; $x=$objTextBox.Text; $usrin=$objTextBox2.Text; $source=$objTextBox3.Text;  $objForm.Close()})
$objForm.Controls.Add($CH24Button)

#choice3.1
$CH31Button = New-Object System.Windows.Forms.Button
$CH31Button.Location = New-Object System.Drawing.Size(200,120)
$CH31Button.Size = New-Object System.Drawing.Size(75,23)
$CH31Button.Text = "Non IT Query"
$CH31Button.Add_Click({$y="choice31"; $x=$objTextBox.Text; $usrin=$objTextBox2.Text; $source=$objTextBox3.Text;  $objForm.Close()})
$objForm.Controls.Add($CH31Button)

#choice3.2
$CH32Button = New-Object System.Windows.Forms.Button
$CH32Button.Location = New-Object System.Drawing.Size(200,144)
$CH32Button.Size = New-Object System.Drawing.Size(75,23)
$CH32Button.Text = "choice"
$CH32Button.Add_Click({$y="choice32"; $source=$objTextBox3.Text;  $objForm.Close()})
$objForm.Controls.Add($CH32Button)

#choice3.3
$CH33Button = New-Object System.Windows.Forms.Button
$CH33Button.Location = New-Object System.Drawing.Size(200,168)
$CH33Button.Size = New-Object System.Drawing.Size(75,23)
$CH33Button.Text = "choice"
$CH33Button.Add_Click({$y="choice33";  $source=$objTextBox3.Text; $objForm.Close()})
$objForm.Controls.Add($CH33Button)

#choice3.4
$CH34Button = New-Object System.Windows.Forms.Button
$CH34Button.Location = New-Object System.Drawing.Size(200,192)
$CH34Button.Size = New-Object System.Drawing.Size(75,23)
$CH34Button.Text = "choice"
$CH34Button.Add_Click({$y="choice34"; $source=$objTextBox3.Text;  $objForm.Close()})
$objForm.Controls.Add($CH34Button)

#Cancel
$CancelButton = New-Object System.Windows.Forms.Button
$CancelButton.Location = New-Object System.Drawing.Size(100,235)
$CancelButton.Size = New-Object System.Drawing.Size(75,23)
$CancelButton.Text = "Close"
$CancelButton.Add_Click({$exit = 1; $source = ""; $objForm.Close()})
$objForm.Controls.Add($CancelButton)

# UserName box
$objLabel = New-Object System.Windows.Forms.Label
$objLabel.Location = New-Object System.Drawing.Size(10,20) 
$objLabel.Size = New-Object System.Drawing.Size(150,20) 
$objLabel.Text = "User Name"
$objForm.Controls.Add($objLabel) 

$objTextBox = New-Object System.Windows.Forms.TextBox 
$objTextBox.Location = New-Object System.Drawing.Size(10,40) 
$objTextBox.Size = New-Object System.Drawing.Size(150,20) 
$objForm.Controls.Add($objTextBox) 

# Source box
$objLabel = New-Object System.Windows.Forms.Label
$objLabel.Location = New-Object System.Drawing.Size(170,20) 
$objLabel.Size = New-Object System.Drawing.Size(280,20) 
$objLabel.Text = "Source (E,P or W)"
$objForm.Controls.Add($objLabel) 

$objTextBox3 = New-Object System.Windows.Forms.TextBox 
$objTextBox3.Location = New-Object System.Drawing.Size(170,40) 
$objTextBox3.Size = New-Object System.Drawing.Size(90,20) 
$objForm.Controls.Add($objTextBox3) 

# Problem text box
$objLabel = New-Object System.Windows.Forms.Label
$objLabel.Location = New-Object System.Drawing.Size(10,60) 
$objLabel.Size = New-Object System.Drawing.Size(280,20) 
$objLabel.Text = "Description"
$objForm.Controls.Add($objLabel) 

$objTextBox2 = New-Object System.Windows.Forms.TextBox 
$objTextBox2.Location = New-Object System.Drawing.Size(10,80) 
$objTextBox2.Size = New-Object System.Drawing.Size(260,20) 
$objForm.Controls.Add($objTextBox2) 

$objForm.Topmost = $True

$objForm.Add_Shown({$objForm.Activate()})
[void] $objForm.ShowDialog()

# username and job are now x and y


}