Skip to content

Instantly share code, notes, and snippets.

Avatar

Darren Robinson darrenjrobinson

View GitHub Profile
@darrenjrobinson
darrenjrobinson / schema.ps1
Last active Apr 1, 2021
Using the new Granfeldt FIM/MIM PowerShell Management Features - Schema Script. Associated Blogpost https://blog.darrenjrobinson.com/using-the-new-granfeldt-fim-mim-powershell-management-features/
View schema.ps1
$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"
@darrenjrobinson
darrenjrobinson / Microsoft Graph using MSAL with Python and Delegated Permissions.py
Last active Jun 8, 2021
Microsoft Graph using MSAL with Python and Delegated Permissions using a persistent local MSAL Cache. Associated Blogpost https://blog.darrenjrobinson.com/microsoft-graph-using-msal-with-python-and-delegated-permissions/
View Microsoft Graph using MSAL with Python and Delegated Permissions.py
import msal
import jwt
import json
import sys
import requests
from datetime import datetime
from msal_extensions import *
graphURI = 'https://graph.microsoft.com'
tenantID = 'yourTenantID'
@darrenjrobinson
darrenjrobinson / Import.ps1
Last active Apr 12, 2021
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/
View Import.ps1
PARAM
(
$Username,
$Password,
$Credentials,
$OperationType,
[bool] $usepagedimport,
[int]$pagesize
)
@darrenjrobinson
darrenjrobinson / Schema.ps1
Last active Apr 15, 2021
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/
View Schema.ps1
$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"
View Get Azure AD Authentication Methods Summary Reports.ps1
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 Sep 8, 2021
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
View GetStaleAADGuestAccounts.ps1
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 Oct 5, 2021
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/
View Get-AzureADAuthenticationMethods.ps1
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.
View getM365AppUserDetail.ps1
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.
View Get Certificate from Windows CertStore.py
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 Aug 17, 2021
Authenticate and Query Microsoft Graph using MSAL and Python. Associated blogpost https://blog.darrenjrobinson.com/microsoft-graph-using-msal-with-python/
View Auth_Query_MSGraph_MSAL.py
import msal
import jwt
import json
import requests
import pandas as pd
from datetime import datetime
accessToken = None
requestHeaders = None
tokenExpiry = None