$license_server = 'http://10.138.253.108:8080/v1/admin/status' # test public # $workflow_server = 'https://prod-172.westus.logic.azure.com:443/workflows/ff2e50d150a4497fa5fb3998f19ff64d/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=7nd4_UM0vfGR4mS1853KGfmdla099Rg10JfGnaG07FE' # server status $workflow_server = 'https://prod-184.westus.logic.azure.com:443/workflows/0196c82aa13d4700b207cf20cf32689d/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=WS67Db7ck2pwmjkNopNBWOiNjlO2jwZdLk71oTQjW_8' $adaptive_card = @{ type = 'message' attachments = @( @{ contentType = 'application/vnd.microsoft.card.adaptive' content = @{ '$schema' = 'http://adaptivecards.io/schemas/adaptive-card.json' type = 'AdaptiveCard' version = '1.0' msteams = @{ width = 'Full' } body = @( @{ type = 'TextBlock' text = 'Unity License Server Status' wrap = $True color = 'good' size = 'large' weight = 'bolder' } ) } } ) } $response = Invoke-WebRequest -Method 'GET' -Uri $license_server -SkipHttpErrorCheck if ($response.StatusCode -ne '200') { $json = (ConvertFrom-Json ([System.Text.Encoding]::UTF8.GetString($response.Content)) | ConvertTo-Json) $adaptive_card.attachments[0].content.body += @{ type = 'CodeBlock' language = 'JSON' codeSnippet = $json } } else { $json = (ConvertFrom-Json ([System.Text.Encoding]::UTF8.GetString($response.Content)) | ConvertTo-Json) $adaptive_card.attachments[0].content.body += @{ type = 'FactSet' facts = @( @{ title = 'Name' value = $json.serverContext.data.MachineName } @{ title = 'Status' value = $json.serverStatus } @{ title = 'Up Time' value = $json.serverUpTime } ) } $table = @{ type = 'Table' firstRowAsHeaders = $true columns = @( @{ width = 1 } @{ width = 1 } @{ width = 1 } ) rows = @( @{ type = 'TableRow' cells = @( @{ type = 'TableCell' items = @( @{ type = 'TextBlock' text = 'Product' weight = 'Bolder' } ) } @{ type = 'TableCell' items = @( @{ type = 'TextBlock' text = 'Active Licenses' weight = 'Bolder' } ) } @{ type = 'TableCell' items = @( @{ type = 'TextBlock' text = 'Total Licenses' weight = 'Bolder' } ) } ) } ) } foreach ($license in $json.serverLicenses.data) { $table.rows += @{ type = 'TableRow' cells = @( @{ type = 'TableCell' items = @( @{ type = 'TextBlock' text = $license.Product } ) } @{ type = 'TableCell' items = @( @{ type = 'TextBlock' text = "$($license.activeLicenseCount)" } ) } @{ type = 'TableCell' items = @( @{ type = 'TextBlock' text = "$($license.licenseCount)" } ) } ) } } $adaptive_card.attachments[0].content.body += $table } Invoke-WebRequest -Uri $workflow_server -Method Post -Body (ConvertTo-Json -InputObject $adaptive_card -Depth 99) -ContentType 'application/json'