Skip to content

Instantly share code, notes, and snippets.

### Azure AD / M365 profile picture uploader
### Version 1.0
### Author: Alexander Holmeset
### Email: alexander.holmeset@gmail.com
### Twitter: twitter.com/alexholmeset
### Blog: alexholmeset.blog
$TenantId = "xxxxxxx"
$ClientID = "xxxxxx"
$ClientSecret = "xxxxx"
#Updated for Teams v2!
#Blog: Alexholmeset.blog
#Import the Azure AD Internals module.
Import-Module AADInternals
#Users to process
$Users = import-csv c:\temp\users.csv
foreach($user in $users){
# Name: SetCalendarPermissions.ps1
# Description: This script sets the default calendar permissions for all users in a Microsoft 365 organization to LimitedRead.
# Author: Alexander Holmeset
# CoContributor: Simon Skotheimsvik, http://skotheimsvik.no, https://x.com/SSkotheimsvik
# Version: 1.0
# Date: 2021-09-01
# Blog: https://alexholmeset.blog
# X(Twitter): https://x.com/AlexHolmeset
# Set the permission level to be set on the calendars.
#Requires -Modules Microsoft.Graph.Authentication
#Requires -Modules Microsoft.Graph.Applications
# Install the module. (You need admin on the machine.)
# Install-Module Microsoft.Graph
# Set Static Variables
$TenantID="enter here"
$AutomationAccountDisplayname ="enter here"
# Define dynamic variables
# This function takes a path to a file as a parameter and returns the base64 string of that file.
function Get-Photo {
param (
[Parameter(Mandatory=$true)]
[string]$path
)
[convert]::ToBase64String((get-content $path -Raw -AsByteStream))
}
{
"type": "object",
"properties": {
"id": {
"type": "string"
},
"object": {
"type": "string"
},
"created": {
{
"messages": [
{
"role": "system",
"content": "You are a helpful assistant. You reply to all emails for me. My signature should be Alexander Holmeset, Senior Cloud Consultant, Contoso. You can reply in all languages. format your reply in html"
},
{
"role": "user",
"content": "@{item()?['bodyPreview']}. The following is a history of previous emails, dont add it to your reply. @{variables('EmailHistory')}"
}
# Connect to Azure Account
Connect-AzAccount
# Connect to Microsoft Teams
Connect-MicrosoftTeams
# Connect to Exchange Online
Connect-ExchangeOnline
# Connect to SharePoint Online
$SPConnection = Connect-PnPOnline -Url https://alexholmeset-admin.sharepoint.com -Interactive
# Get access token for Microsoft Graph API
function Get-AzureOpenAIToken1{
<# .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.
,
"additionalLoginParams": [
"response_type=code id_token",
"https://graph.microsoft.com",
"(String)"
]