Utils/ServicePortal.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<#
    .NOTES
    ===========================================================================
     Created with: SAPIEN Technologies, Inc., PowerShell Studio 2019 v5.6.157
     Created on: 2/20/2019 22:59
     Created by: jisodl0
     Organization:
     Filename: ServicePortal.ps1
    ===========================================================================
    .DESCRIPTION
        A collection of functions for interacting with the J. B. Hunt IT Service
  Portal.
#>


$ChromePath = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
$ServicePortalURL = "http://itrequests.jbhunt.com"

<#
    .SYNOPSIS
        Opens an Incident Record in the J.B. Hunt IT Service Portal.
    
    .PARAMETER IRNumber
        The number of the IR to open.
    
    .EXAMPLE
        PS C:\> Open-IncidentRecord -IRNumber '5772012'
#>

function Open-IncidentRecord {
  [CmdletBinding()]
  [Alias('Open-IR', 'oir')]
  param (
    [Parameter(Mandatory = $true, Position = 0)]
    [Alias('IR')]
    [String]
    $IRNumber
  )
  
  if (($IRNumber.StartsWith("IR")) -eq $false -and $IRNumber.Length -eq 7) {
    $IRNumber = "IR$IRNumber"
  }
  
  Start-Process -FilePath $ChromePath -ArgumentList "$ServicePortalURL/Incident/Edit/$IRNumber"
}

<#
    .SYNOPSIS
        Opens a Change Record in the J.B. Hunt IT Service Portal.
    
    .PARAMETER CRNumber
        The number of the CR to open.
    
    .EXAMPLE
        PS C:\> Open-ChangeRecord -CRNumber '5772012'
#>

function Open-ChangeRecord {
  [CmdletBinding()]
  [Alias('Open-CR', 'ocr')]
  param (
    [Parameter(Mandatory = $true, Position = 0)]
    [Alias('CR')]
    [String]
    $CRNumber
  )
  
  if (($CRNumber.StartsWith("CR")) -eq $false -and $CRNumber.Length -eq 7) {
    $CRNumber = "CR$CRNumber"
  }
  
  Start-Process -FilePath $ChromePath -ArgumentList "$ServicePortalURL/ChangeRequest/Edit/$CRNumber"
}

<#
    .SYNOPSIS
        Opens a Service Record in the J.B. Hunt IT Service Portal.
    
    .PARAMETER SRNumber
        The number of the SR to open.
    
    .EXAMPLE
        PS C:\> Open-ServiceRecord -SR '5772012'
#>

function Open-ServiceRecord {
  [CmdletBinding()]
  [Alias('Open-SR', 'osr')]
  param (
    [Parameter(Mandatory = $true, Position = 0)]
    [Alias('SR')]
    [String]
    $SRNumber
  )
  
  if (($SRNumber.StartsWith("SR")) -eq $false -and $SRNumber.Length -eq 7) {
    $SRNumber = "SR$SRNumber"
  }
  
  Start-Process -FilePath $ChromePath -ArgumentList "$ServicePortalURL/ServiceRequest/Edit/$SRNumber"
}