Skip to content

Instantly share code, notes, and snippets.

Glen Scales gscales

Block or report user

Report or block gscales

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:337bb23013e26842bb86d9aad8f82b4a
$ClientId = "12d09d34-c3a3-49fc-bdf7-e059801801ae"
$MailboxName = "gscales@datarumble.com"
$KeyVaultURL = "https://gspskeys.vault.azure.net/secrets/App1AuthCert/xxx99c5d054f43698f39c51f24440xxx?api-version=7.0"
Import-Module .\Microsoft.IdentityModel.Clients.ActiveDirectory.dll -Force
$TenantId = (Invoke-WebRequest -Uri ('https://login.windows.net/' + $MailboxName.Split('@')[1] + '/.well-known/openid-configuration') | ConvertFrom-Json).authorization_endpoint.Split('/')[3]
$SptokenResult = Invoke-WebRequest -Uri 'http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https%3A%2F%2Fvault.azure.net' -Headers @{Metadata="true"}
$Sptoken = ConvertFrom-Json $SptokenResult.Content
$headers = @{
'Content-Type' = 'application\json'
View gist:8fe0f836d3ad4687cff850e5ac7d20d6
$KeyVaultURL = "https://xxx.vault.azure.net/secrets/App1AuthCert/xxx99c5d054f43698f39c51f24440xxx?api-version=7.0"
$SptokenResult = Invoke-WebRequest -Uri 'http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https%3A%2F%2Fvault.azure.net' -Headers @{Metadata="true"}
$Sptoken = ConvertFrom-Json $SptokenResult.Content
$headers = @{
'Content-Type' = 'application\json'
'Authorization' = 'Bearer ' + $Sptoken.access_token
}
$Response = (Invoke-WebRequest -Uri $KeyVaultURL -Headers $headers)
$certResponse = ConvertFrom-Json $Response.Content
View gist:3645324ee264fe91d7b26cd7c8a3e773
function Connect-Exchange {
param(
[Parameter(Position = 0, Mandatory = $true)] [string]$MailboxName,
[Parameter(Position = 1, Mandatory = $false)] [string]$url,
[Parameter(Position = 2, Mandatory = $false)] [string]$ClientId,
[Parameter(Position = 3, Mandatory = $false)] [string]$redirectUrl,
[Parameter(Position = 4, Mandatory = $false)] [string]$AccessToken,
[Parameter(Position = 5, Mandatory = $false)] [switch]$basicAuth,
[Parameter(Position = 6, Mandatory = $false)] [System.Management.Automation.PSCredential]$Credentials
@gscales
gscales / gist:838addbd1424f31e6c1411435de89c1a
Created Jun 21, 2019
Access the Team Meeting CDR's folder using EWS
View gist:838addbd1424f31e6c1411435de89c1a
$folderid= new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Root,$MailboxName)
$TeamMeetingsFolderEntryId = new-object Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition([System.Guid]::Parse("{07857F3C-AC6C-426B-8A8D-D1F7EA59F3C8}"), "TeamsMeetingsFolderEntryId", [Microsoft.Exchange.WebServices.Data.MapiPropertyType]::Binary);
$psPropset= new-object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties)
$psPropset.Add($TeamMeetingsFolderEntryId)
$RootFolder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$folderid,$psPropset)
$FolderIdVal = $null
$TeamsMeetingFolder = $null
if ($RootFolder.TryGetProperty($TeamMeetingsFolderEntryId,[ref]$FolderIdVal))
{
View gist:a2886667b0855c63ad6661ab35ee1aa4
function Get-TenantId {
param(
[Parameter(Position = 1, Mandatory = $false)]
[String]$DomainName
)
Begin {
$RequestURL = "https://login.windows.net/{0}/.well-known/openid-configuration" -f $DomainName
Add-Type -AssemblyName System.Net.Http
$handler = New-Object System.Net.Http.HttpClientHandler
View gist:6dfff3c1eef5d9f62fcb740a05f70253
function Get-TenantId {
param(
[Parameter(Position = 1, Mandatory = $false)]
[String]$DomainName
)
Begin {
$RequestURL = "https://login.windows.net/{0}/.well-known/openid-configuration" -f $DomainName
Add-Type -AssemblyName System.Net.Http
$handler = New-Object System.Net.Http.HttpClientHandler
View gist:a2d325a0fe6bde32f355b136b16c0927
param(
[Parameter(Position = 0, Mandatory = $false)]
[object]
$WebhookData
)
function Invoke-PresenceDLCheck {
param(
[Parameter(Position = 0, Mandatory = $false)]
View gist:cf851dcd9854f523045e1dd8dbe73689
#r "Newtonsoft.Json"
using System.Net;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
public static async Task<IActionResult> Run(HttpRequest req, ILogger log)
View designer.html
<link rel="import" href="../google-map/google-map.html">
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../ace-element/ace-element.html">
<polymer-element name="my-element">
<template>
<style>
:host {
@gscales
gscales / gist:26d9fa299b3de5f86a15
Created May 1, 2015
Powershell Online Calendar sample
View gist:26d9fa299b3de5f86a15
Invoke-RestMethod -Uri ("https://outlook.office365.com/api/v1.0/users/sharedmailbox@domain.com/calendarview?startDateTime=" + (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddThh:mm:ssZ") + "&endDateTime=" + (Get-Date).ToUniversalTime().AddDays(7).ToString("yyyy-MM-ddThh:mm:ssZ")) -Credential (Get-Credential) | foreach-object{$_.Value}
You can’t perform that action at this time.