Skip to content

Instantly share code, notes, and snippets.

@jrwarwick
Last active October 14, 2021 19:57
Show Gist options
  • Save jrwarwick/3f9701a56852dfd430513a62df27bad9 to your computer and use it in GitHub Desktop.
Save jrwarwick/3f9701a56852dfd430513a62df27bad9 to your computer and use it in GitHub Desktop.
DIY Virtual assistant uses TTS to read off a summary morning status report to you, if you schedule it with Windows Task Scheduler
#speech
$vox = New-Object -com SAPI.spvoice
$vox.speak("Testing testing 1 2 3")
#id knowledge
$vox.speak("Hello and welcome, $($env:username.substring(0,1)) $($env:username.substring(1))")
#time knowledge
$daysegments = @("Night","Morning","Morning","Afternoon","Evening","Night")
$curseg = [math]::Floor(((get-date -Uformat "%H") -5) / 4) + 1
$vox.speak("Good $($daysegments[$curseg]) $($env:username.substring(0,1)) $($env:username.substring(1))")
#network connectivity knowledge
$servernames = @("athena","hecate","pan","hermes","vulcan")
foreach ($servername in $servernames) {
if (test-connection -ComputerName "$($servername).$($env:userdnsdomain)" -Count 2) {
$vox.speak("$($servername) is online.")
} else {
$vox.speak("WARNING! $($servername) is OFFLINE! Repeat: $($servername) is OFFLINE!");
}
}
#consume an ATOM/RSS feed or SOAP here on Remedy tickets
# Adapted from some Greg Elphic GOLD: https://communities.bmc.com/thread/65122?tstart=0
# SOAP interface through WSDL object can be a URL or file copy as long as the service target is in the file
#$ars = [System.Uri] "https://longview.onbmc.com/arsys/WSDL/public/onbmc-s/HPD_IncidentInterface_WS"
### UGH! https://psvmware.wordpress.com/2015/01/22/helpdesk_querylist_service-with-3-arguments-there-is-an-error-in-xml-document-3-4/
### probably a broken wsdl! so file it is...
$ars = [System.Uri] "C:\temp\HPD_IncidentInterface_WS.xml"
$proxy = New-WebServiceProxy -Uri $ars
# With LVS Remedy to access data that is not public you will have to have a named licence user
function New-ObjectFromProxy {
param($proxy, $proxyAttributeName, $typeName)
# Locate the assembly for $proxy
$attribute = $proxy | gm | where { $_.Name -eq $proxyAttributeName }
$str = "`$assembly = [" + $attribute.TypeName + "].assembly"
invoke-expression $str
# Instantiate an AuthenticationHeaderValue object.
$type = $assembly.getTypes() | where { $_.Name -eq $typeName }
return $assembly.CreateInstance($type)
}
# Before continuing we need to add an Authentication Header to $proxy
$authHeader = New-ObjectFromProxy -proxy $proxy -proxyAttributeName "AuthenticationInfoValue" -typeName "AuthenticationInfo"
$authHeader.userName = "USERNAMEFOO"
$authHeader.password = "SECRE+Pa55w0rd"
#$authHeader.authentication = ""
#$authHeader.locale = ""
#$authHeader.timeZone = ""
$proxy.AuthenticationInfoValue = $authHeader
#Ok setup complete, now do something.
$query_qualification = @"
('Assigned Group'="My Foo Groop" AND 'Status' != "Closed" )
AND ( 'VIP' = "Yes" OR ('Assignee' LIKE "%MyFoo FooName%" AND 'Priority' = "High" ) )
"@
$hipri_inc_summary = ""
$proxy.HelpDesk_QueryList_Service($query_qualification ,1,10) | select first_name, last_name, Urgency, Priority, Impact, VIP, Summary |%{ $hipri_inc_summary += "{0} {1} reports: {2} . And, " -f $_.first_name, $_.last_name, $_.Summary }
if ($hipri_inc_summary.length -gt 4) {
$vox.speak($hipri_inc_summary)
$vox.speak(" that is all.")
} else {
$vox.speak("No high-priority Remedy incidents requiring your attention.")
}
#glance at the Exchange Calendar here
#Unread messages in inbox:
# # from important people, addressed to me directly
# # marked with ! important
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment