Skip to content

Instantly share code, notes, and snippets.

View darrenjrobinson's full-sized avatar

Darren Robinson darrenjrobinson

View GitHub Profile
@darrenjrobinson
darrenjrobinson / Import.ps1
Last active April 12, 2021 01:04
Granfeldt PowerShell Dynamics 365 Finance & Operations Management Agent for Microsoft Identity Manager. Import Script. Associated Blogpost https://blog.darrenjrobinson.com/a-dynamics-365-finance-operations-management-agent-for-microsoft-identity-manager/
PARAM
(
$Username,
$Password,
$Credentials,
$OperationType,
[bool] $usepagedimport,
[int]$pagesize
)
@darrenjrobinson
darrenjrobinson / Schema.ps1
Last active April 15, 2021 23:41
Granfeldt PowerShell Dynamics 365 Finance & Operations Management Agent for Microsoft Identity Manager. Schema Script. Associated Blogpost https://blog.darrenjrobinson.com/a-dynamics-365-finance-operations-management-agent-for-microsoft-identity-manager/
$obj = New-Object -Type PSCustomObject
$obj | Add-Member -Type NoteProperty -Name "Anchor-Employee ID|String" -Value ""
$obj | Add-Member -Type NoteProperty -Name "objectClass|String" -Value "person"
$obj | Add-Member -Type NoteProperty -Name "First Name|string" -Value "string"
$obj | Add-Member -Type NoteProperty -Name "Last Name|string" -Value "string"
$obj | Add-Member -Type NoteProperty -Name "Title|string" -Value "string"
$obj | Add-Member -Type NoteProperty -Name "Department|string" -Value "string"
$obj | Add-Member -Type NoteProperty -Name "Employee Type|string" -Value "string"
$obj | Add-Member -Type NoteProperty -Name "Employment Start Date|string" -Value "string"
$obj | Add-Member -Type NoteProperty -Name "Employment End Date|string" -Value "string"
Function DelegatedAuthN {
<#
.SYNOPSIS
Authenticate to Azure AD (using Delegated Auth) and receieve Access and Refresh Tokens.
.DESCRIPTION
Authenticate to Azure AD (using Delegated Auth) and receieve Access and Refresh Tokens.
.PARAMETER tenantID
@darrenjrobinson
darrenjrobinson / GetStaleAADGuestAccounts.ps1
Last active September 8, 2021 13:35
Get all AAD B2B Guest Accounts which haven't signed in, in the last XX Days, or haven't accepted a B2B Guest Invitation in last XX Days. Associated Blogpost https://blog.darrenjrobinson.com/finding-stale-azure-ad-b2b-guest-accounts-based-on-lastsignindatetime
Function AuthN {
<#
.SYNOPSIS
Authenticate to Azure AD and receieve Access and Refresh Tokens.
.DESCRIPTION
Authenticate to Azure AD and receieve Access and Refresh Tokens.
.PARAMETER tenantID
(required) Azure AD TenantID.
@darrenjrobinson
darrenjrobinson / Get-AzureADAuthenticationMethods.ps1
Last active November 1, 2021 18:51
PowerShell script to retrieve Azure AD Users Authentication Methods and add them as additional attributes on the User Object. Associated Blogpost https://blog.darrenjrobinson.com/reporting-on-users-azure-ad-authentication-methods-using-microsoft-graph-and-powershell/
Function AuthN {
<#
.SYNOPSIS
Authenticate to Azure AD and receieve Access and Refresh Tokens.
.DESCRIPTION
Authenticate to Azure AD and receieve Access and Refresh Tokens.
.PARAMETER tenantID
(required) Azure AD TenantID.
@darrenjrobinson
darrenjrobinson / getM365AppUserDetail.ps1
Last active February 2, 2023 12:06
Getting Microsoft 365 Individual User Usage Report with PowerShell. Associated Blogpost https://blog.darrenjrobinson.com/getting-microsoft-365-individual-user-usage-reports-with-powershell/
Function AuthN {
<#
.SYNOPSIS
Authenticate to Azure AD and receieve Access and Refresh Tokens.
.DESCRIPTION
Authenticate to Azure AD and receieve Access and Refresh Tokens.
.PARAMETER tenantID
(required) Azure AD TenantID.
import wincertstore
import base64
import ssl
import os
from cryptography import x509
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
from cryptography.x509.oid import ExtensionOID
# Certificate Name & Thumbprint to look for
@darrenjrobinson
darrenjrobinson / Auth_Query_MSGraph_MSAL.py
Last active November 30, 2022 22:48
Authenticate and Query Microsoft Graph using MSAL and Python. Associated blogpost https://blog.darrenjrobinson.com/microsoft-graph-using-msal-with-python/
import msal
import jwt
import json
import requests
import pandas as pd
from datetime import datetime
accessToken = None
requestHeaders = None
tokenExpiry = None
@darrenjrobinson
darrenjrobinson / run.ps1
Last active October 17, 2020 05:12
PowerShell Azure Function SendGrid Output Binding example. Associated Blogpost https://blog.darrenjrobinson.com/using-the-azure-functions-sendgrid-output-binding-with-powershell/
using namespace System.Net
# Input bindings are passed in via param block.
param($Request, $TriggerMetadata)
# Write to the Azure Functions log stream.
Write-Host "PowerShell HTTP trigger function processed a request."
$inputData = $Request.Body | convertfrom-json
$emailSubject = $inputData.subject
$mail = @{
"personalizations" = @(
@{
"to" = @(
@{
"email" = "$($env:sendGridToAddress)"
}
)
}
)