Skip to content

Instantly share code, notes, and snippets.

Avatar

Darren Robinson darrenjrobinson

View GitHub Profile
@darrenjrobinson
darrenjrobinson / Auth_Query_MSGraph_MSAL.py
Last active Nov 26, 2020
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
@darrenjrobinson
darrenjrobinson / run.ps1
Last active Oct 17, 2020
PowerShell Azure Function SendGrid Output Binding example. Associated Blogpost https://blog.darrenjrobinson.com/using-the-azure-functions-sendgrid-output-binding-with-powershell/
View run.ps1
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
View SendGrid Message Format from a PowerShell Azure Function.ps1
$mail = @{
"personalizations" = @(
@{
"to" = @(
@{
"email" = "$($env:sendGridToAddress)"
}
)
}
)
@darrenjrobinson
darrenjrobinson / Get Time Series Prediction.ps1
Last active Jul 21, 2020
Get Prediction using H2O AI for an a Time Series Dataset using the H2OAI PowerShell Module. Associated Blogpost https://blog.darrenjrobinson.com/h2o-ai-powershell-module/
View Get Time Series Prediction.ps1
# Linear Regression Model
$modelAlgorithm = 'glm'
# Time Series Data
$dataCSV = "C:\data\A2B-AX-3y.csv"
$sourceData = Import-Csv $dataCSV
# Last Record as Prediction data
$dataPredict = Import-Csv -Path $dataCSV | Select-Object -Last 1 | export-csv ./dataPredict.csv
@darrenjrobinson
darrenjrobinson / Get Iris Prediction.ps1
Last active Jul 21, 2020
Get Prediction using H2O AI for an Iris using the H2OAI PowerShell Module. Associated Blogpost https://blog.darrenjrobinson.com/h2o-ai-powershell-module/
View Get Iris Prediction.ps1
# Default H2O AI Server running locally via Start-H2O
$url = "http://localhost:54321/3/{0}"
# Neural net algorithm for determining Iris type
$modelAlgorithm = 'deeplearning'
# Get Iris Training data and put on the local filesystem
Invoke-RestMethod -Method Get 'https://raw.githubusercontent.com/DarrenCook/h2o/bk/datasets/iris_wheader.csv' | out-file ./iris_wheader.csv
# Prediction Column
$predictValues = 'class'
View SailPoint IdentityNow PowerShell Module Examples.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@darrenjrobinson
darrenjrobinson / B2B Member Invite
Last active Aug 26, 2020
Convert Azure Active Directory AAD User from Member to B2B Member. Associated blogpost https://blog.darrenjrobinson.com/convert-azure-ad-users-from-members-to-b2b-members/
View B2B Member Invite
# Invite User Request
$inviteDetails = @{
"invitedUserEmailAddress" = $externalEmail.otherMails[0]
"invitedUser" = @{"id" = $updatedUser.id }
"sendInvitationMessage" = $true
"inviteRedirectUrl" = "https://myapps.microsoft.com?ResourceTenantName.com"
"invitedUserMessageInfo" = @{
"messageLanguage" = "en-AU"
"customizedMessageBody" = "Hi $($updatedUser.displayName), Your user account '$($updatedUser.userPrincipalName)' in the Contoso Azure Tenant has been migrated to a Guest account federated to your Fabrikam '$($updatedUser.otherMails[0])' account. After selecting 'Get Started' below you will be able to access Contoso using your Fabrikam account and credentials. All you access and privilages remain intact. Regards, Contoso IT"
}
@darrenjrobinson
darrenjrobinson / Update otherMails AAD User attribute.ps1
Last active Apr 26, 2020
Update AzureAD User otherMails attribute to allow conversion from AAD Member to AAD B2B Member. Associated blogpost https://blog.darrenjrobinson.com/convert-azure-ad-users-from-members-to-b2b-members/
View Update otherMails AAD User attribute.ps1
Import-Module MSAL.PS -RequiredVersion 4.7.1.1
$tenantID = "myTenant.onmicrosoft.com"
$clientID = "yourRegistedAppID"
$clientSecret = (ConvertTo-SecureString "yourRegistedAppSecret" -AsPlainText -Force)
$accessToken = Get-MsalToken -clientID $clientID -clientSecret $clientSecret -tenantID $tenantID -ForceRefresh | Select-Object -Property AccessToken
$users = Invoke-RestMethod -Headers @{Authorization = "Bearer $($accessToken.AccessToken)" } `
-Uri 'https://graph.microsoft.com/v1.0/users' `
View Getting started with a Local PowerShell Jupyter Notebook.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@darrenjrobinson
darrenjrobinson / Audit Azure AD Registered Applications.ps1
Last active Feb 22, 2020
Enumerate Azure AD Registered Apps for expiring credentials and sign-in activity. Associated blogpost https://blog.darrenjrobinson.com/auditing-azure-ad-registered-applications/
View Audit Azure AD Registered Applications.ps1
# Creds
$tenantID = 'yourAADTenantID'
$clientID = 'aadAppID'
$clientSecret = (ConvertTo-SecureString 'aadAppSecret' -AsPlainText -Force)
$accessToken = Get-MsalToken -clientID $clientID -clientSecret $clientSecret -tenantID $tenantID | Select-Object -Property AccessToken
# MS Graph Apps URI
$aadAppsURI = 'https://graph.microsoft.com/v1.0/applications'
# Get Expiring Creds in x Days
$expiryCheck = 60
You can’t perform that action at this time.