added funcs for working with tickets
This commit is contained in:
@@ -12,6 +12,9 @@
|
||||
# Define the root path for the MSP in the Windows Registry
|
||||
[string]$Global:MSPRegistryRoot = "HKEY_LOCAL_MACHINE\SOFTWARE\${MSPName}"
|
||||
|
||||
# Create a global variable to keep a ticket number if it needs to be used by any scripts
|
||||
$Global:TicketNumber = $null
|
||||
|
||||
# Setup the MSP management directories
|
||||
Function Setup-MSPDirectories {
|
||||
If ( Test-Path ${Env:ProgramData} ) { $Global:RootDirectory = "${Env:ProgramData}\${MSPName}" } Else { $Global:RootDirectory = "${Env:SystemDrive}\${MSPName}" }
|
||||
@@ -1032,6 +1035,38 @@ Function Install-LocalTools () {
|
||||
}
|
||||
}
|
||||
|
||||
Function Import-RMMModule () {
|
||||
Try { Import-Module $env:SyncroModule -WarningAction SilentlyContinue -ErrorAction Stop }
|
||||
Catch { Write-Error $_.Exception.Message ; Return }
|
||||
}
|
||||
|
||||
Function New-RMMTicket () {
|
||||
param(
|
||||
[Parameter(ValueFromPipeline=$false,Mandatory=$true)][string]$Subject,
|
||||
[Parameter(ValueFromPipeline=$false,Mandatory=$false)][string]$IssueType="Remote Support",
|
||||
[Parameter(ValueFromPipeline=$false,Mandatory=$true)][string]$InitialIssue
|
||||
)
|
||||
Import-RMMModule
|
||||
Try { $Ticket = Create-Syncro-Ticket -Subject $Subject -IssueType $IssueType -Status "New" }
|
||||
Catch { Write-Error $_.Exception.Message ; Return }
|
||||
$Global:TicketNumber = $Ticket.ticket.id
|
||||
New-TicketComment -TicketID $Global:TicketNumber -Subject "Issue" -Comment $InitialIssue -Hidden -DoNotEmail
|
||||
}
|
||||
|
||||
Function New-TicketComment () {
|
||||
param(
|
||||
[Parameter(ValueFromPipeline=$false,Mandatory=$false)]$TicketID=$null,
|
||||
[Parameter(ValueFromPipeline=$false,Mandatory=$false)][string]$Subject="Update",
|
||||
[Parameter(ValueFromPipeline=$true,Mandatory=$true)][string]$Comment,
|
||||
[Parameter(ValueFromPipeline=$false,Mandatory=$false)][switch]$Hidden=$false,
|
||||
[Parameter(ValueFromPipeline=$false,Mandatory=$false)][switch]$DoNotEmail=$false
|
||||
)
|
||||
If ( ($null -eq $TicketID) -and ($null -eq $Global:TicketNumber) ) { Return }
|
||||
If ( ($null -eq $TicketID) -and ($null -ne $Global:TicketNumber) ) { $TicketID = $Global:TicketNumber }
|
||||
Try { Create-Syncro-Ticket-Comment -TicketIdOrNumber $TicketID -Subject $Subject -Body $Comment -Hidden $Hidden -DoNotEmail $DoNotEmail }
|
||||
Catch { Write-Error $_.Exception.Message ; Return }
|
||||
}
|
||||
|
||||
Setup-MSPDirectories
|
||||
Setup-LogFile
|
||||
Install-LocalTools
|
||||
|
||||
Reference in New Issue
Block a user