Skip to content

Instantly share code, notes, and snippets.

{
"type": "object",
"properties": {
"RowID": {
"type": "string"
},
"Hours": {
"type": "string"
}
}
#Authentication
$consumerToken = "xxxxxx"
$employeeToken = "xxxxxx"
#Add your HTTP Trigger URIs from the cloud flows here:
$AddURI = "xxxxx"
$ReadURI = "xxxxx"
$UpdateURI = "xxxxxx"
{
"displayName": "AlexHolmeset.blog",
"squareLogoWebUrlForDarkTheme": "https://s.w.org/style/images/about/WordPress-logotype-wmark.png",
"longLogoWebUrlForDarkTheme": "https://s.w.org/style/images/about/WordPress-logotype-wmark.png",
"squareLogoWebUrlForLightTheme": "https://s.w.org/style/images/about/WordPress-logotype-wmark.png",
"longLogoWebUrlForLightTheme": "https://s.w.org/style/images/about/WordPress-logotype-wmark.png",
"isEnabled": true,
"loginWebUrl": ""
}
{
"additionalTags": [
"Teams Meetings"
],
"contentWebUrl": "https://alexholmeset.blog/2023/01/25/asdfasdf/",
"contributor": "Alexander Holmeset",
"description": "Put a description here if you have.",
"duration": "PT20M",
"format": "Blog",
"isActive": true,
$graphScope = "LearningContent.ReadWrite.All"
$servicePrincipalObjectId = "Enter object ID of Logic App here"
$TenantID = "contoso.onmicrosoft.com"
Install-Module Microsoft.Graph
Connect-MgGraph -Scope “AppRoleAssignment.ReadWrite.All”,”Application.Read.All” -tenantId $TenantID
$graph = Get-MgServicePrincipal -Filter "AppId eq '00000003-0000-0000-c000-000000000000'"
$graphAppRole = $graph.AppRoles | ? Value -eq $graphScope
https://graph.microsoft.com/beta/employeeExperience/learningProviders/c18f52f8-0cfd-45b2-8f86-3956bc895f66/learningContents(externalId='ENTER TITLE')
function Get-AzureOpenAIToken{
<# .SYNOPSIS
Get an azure token for user or managed identity thats required to authenticate to Azure OpenAI with Rest API.
Also construct the header if you are using an Azure OpenAI API key instead of Azure AD authentication.
.PARAMETER ManagedIdentity
Use this parameter if you want to use a managed identity to authenticate to Azure OpenAI.
.PARAMETER User
Use this parameter if you want to use a user to authenticate to Azure OpenAI.
.PARAMETER APIKey
Use this parameter if you want to use an API key to authenticate to Azure OpenAI.
function Get-Completion {
<# .SYNOPSIS
Get a text completion from Azure OpenAI Completion endpoint.
.PARAMETER DeploymentName
A deployment name should be provided.
.PARAMETER ResourceName
A Resource name should be provided.
.PARAMETER Prompt
A prompt name should be provided.
.PARAMETER Token
Get-AzureOpenAIToken -ManagedIdentity $true
$DeploymentName = "TextModel"
$ResourceName = "AzureOpenAIAlex"
$Prompt = "What is microsoft teams?"
$Request = Get-Completion -DeploymentName $DeploymentName -ResourceName $ResourceName -Maxtokens 100 -Prompt $Prompt
"Genetrated text:"
$Request.choices.text
Get-AzureOpenAIToken -User $true
$DeploymentName = "TextModel"
$ResourceName = "AzureOpenAIAlex"
$Prompt = "What is microsoft teams?"
$Request = Get-Completion -DeploymentName $DeploymentName -ResourceName $ResourceName -Maxtokens 100 -Prompt $Prompt
"Genetrated text:"
$Request.choices.text