Skip to content

Instantly share code, notes, and snippets.

@davejlong
Last active August 28, 2020 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davejlong/a9e31734f42da96a2217520a4912d0cf to your computer and use it in GitHub Desktop.
Save davejlong/a9e31734f42da96a2217520a4912d0cf to your computer and use it in GitHub Desktop.
Using the PSAtera module to automatically switch tickets from Pending to Open when the "Scheduled For" field is today.
Import-Module PSAtera -MinimumVersion 1.4.0
$Tickets = Get-AteraTicketsFiltered -Pending
foreach($Ticket in $Tickets) {
$ScheduledDate = Get-AteraCustomValue -ObjectType Ticket -ObjectID $Ticket.TicketID -FieldName "Scheduled For"
if ($null -eq $ScheduledDate.ValueAsDateTime) { return }
if ((Get-Date -Date $ScheduledDate.ValueAsDateTime) -le (Get-Date)) {
Set-AteraTicket -TicketID $Ticket.TicketID -TicketStatus "Open"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment