Last active
February 24, 2021 21:47
-
-
Save Juanito99/69b7fe999b9f2f4e733f3435cbfec201 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Start-PodeServer { | |
| New-PodeLoggingMethod -File -Name 'errors' -Path C:\WebSrv | Enable-PodeErrorLogging | |
| New-PodeAuthScheme -Form | Add-PodeAuthWindowsLocal -Name 'WinAuth' -NoGroups -Users @('UpReader') -Sessionless | |
| Add-PodeEndpoint -Address * -Port 8118 -Protocol Https -CertificateStoreLocation LocalMachine -CertificateName server.fqdn | |
| Add-PodeRoute -Method Get -Path '/oemAgents' -ScriptBlock { | |
| $oemFilePath = "C:\WebSrv\MonitorOEM\OEMStatus.json" | |
| $oemObjects = Get-Content -Path $oemFilePath | ConvertFrom-Json | |
| $oemAgents = $oemObjects | Where-Object {$_.targettype -eq 'Agent'} | |
| Write-PodeJsonResponse -Value $oemAgents | |
| } | |
| Add-PodeRoute -Method Get -Path '/oemDBInstances' -ScriptBlock { | |
| $oemFilePath = "C:\WebSrv\MonitorOEM\OEMStatus.json" | |
| $oemObjects = Get-Content -Path $oemFilePath | ConvertFrom-Json | |
| $oemDBInstances = $oemObjects | Where-Object {$_.targettype -eq 'Database Instance'} | |
| Write-PodeJsonResponse -Value $oemDBInstances | |
| } | |
| Add-PodeRoute -Method Get -Path '/oemHosts' -ScriptBlock { | |
| $oemFilePath = "C:\WebSrv\MonitorOEM\OEMStatus.json" | |
| $oemObjects = Get-Content -Path $oemFilePath | ConvertFrom-Json | |
| $oemHosts = $oemObjects | Where-Object {$_.targettype -eq 'Host'} | |
| Write-PodeJsonResponse -Value $oemHosts | |
| } | |
| Add-PodeRoute -Method Get -Path '/oemListeners' -ScriptBlock { | |
| $oemFilePath = "C:\WebSrv\MonitorOEM\OEMStatus.json" | |
| $oemObjects = Get-Content -Path $oemFilePath | ConvertFrom-Json | |
| $oemListeners = $oemObjects | Where-Object {$_.targettype -eq 'Listener'} | |
| Write-PodeJsonResponse -Value $oemListeners | |
| } | |
| Add-PodeRoute -Method Get -Path '/oemObjectsByLobAndSite' -ScriptBlock { | |
| $oemFilePath = "C:\WebSrv\MonitorOEM\OEMStatus.json" | |
| $oemObjects = Get-Content -Path $oemFilePath | ConvertFrom-Json | |
| $rtnOemObjects = '' | |
| $lineOfBusiness = '' | |
| $siteCode = '' | |
| $lineOfBusiness = $WebEvent.Query['lineOfBusiness'] | |
| $siteCode = $WebEvent.Query['siteCode'] | |
| if ($lineOfBusiness -ne '' -and $siteCode -ne '') { | |
| $rtnOemObjects = $oemObjects | Where-Object {($_.LineOfBusiness -eq $lineOfBusiness) -and ($_.SiteCode -eq $siteCode)} | |
| $rtnOemObjects = $rtnOemObjects | Sort-Object -Property SiteCode | |
| Write-PodeJsonResponse -Value $rtnOemObjects | |
| } | |
| } | |
| Add-PodeRoute -Method Get -Path '/oemObjectsByLob' -ScriptBlock { | |
| $oemFilePath = "C:\WebSrv\MonitorOEM\OEMStatus.json" | |
| $oemObjects = Get-Content -Path $oemFilePath | ConvertFrom-Json | |
| $rtnOemObjects = '' | |
| $lineOfBusiness = '' | |
| $lineOfBusiness = $WebEvent.Query['lineOfBusiness'] | |
| if ($lineOfBusiness -ne '' -and $siteCode -ne '') { | |
| $rtnOemObjects = $oemObjects | Where-Object {($_.LineOfBusiness -eq $lineOfBusiness)} | |
| $rtnOemObjects = $rtnOemObjects | Sort-Object -Property SiteCode | |
| Write-PodeJsonResponse -Value $rtnOemObjects | |
| } | |
| } | |
| Add-PodeRoute -Method Get -Path '/oemObjectsNotUp' -ScriptBlock { | |
| $oemFilePath = "C:\WebSrv\MonitorOEM\OEMStatus.json" | |
| $oemObjects = Get-Content -Path $oemFilePath | ConvertFrom-Json | |
| $rtnOemObjects = '' | |
| $rtnOemObjects = $oemObjects | Where-Object {($_.Status -ine 'Target Up')} | |
| $rtnOemObjects = $rtnOemObjects | Sort-Object -Property SiteCode | |
| Write-PodeJsonResponse -Value $rtnOemObjects | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment