Skip to content

Instantly share code, notes, and snippets.

View itpropro's full-sized avatar
🏠
Working from home

Jan-Henrik Damaschke itpropro

🏠
Working from home
View GitHub Profile
@itpropro
itpropro / msiGraphApiPermissions.ps1
Created March 14, 2023 20:25
Add Graph API permissions to managed identity
$tenantId = "00000000-0000-0000-0000-000000000000" # Replace with your tenant ID
$graphApiAppId = "00000003-0000-0000-c000-000000000000" # Well known ID
$msiName = "MSINAME" # Name of your managed identity e.g. name of Function or Logic App
$graphPermissions = @("Directory.Read.All", "User.Read.All") # Add or remove permissions
Connect-AzureAD -TenantId $tenantId
$msi = Get-AzureADServicePrincipal -Filter "displayName eq '$msiName'" # Can take a few seconds, add a sleep if necessary
$graphApiAppRegistration = Get-AzureADServicePrincipal -Filter "appId eq '$graphApiAppId'"
$appRoles = $graphApiAppRegistration.AppRoles | Where-Object { $graphPermissions -contains $_.Value -and $_.AllowedMemberTypes -contains "Application" }
foreach ($appRole in $appRoles) {
@jrdmb
jrdmb / Powershell_String_Hashes.ps1
Last active February 11, 2020 21:50
Hash a string in Powershell with various encryption algorithms
#Here is a simple script to hash a string using your chosen cryptography algorithm.
#Usage Examples:
#Get-StringHash "My String to hash" "MD5"
#Get-StringHash "My String to hash" "RIPEMD160"
#Get-StringHash "My String to hash" "SHA1"
#Get-StringHash "My String to hash" "SHA256"
#Get-StringHash "My String to hash" "SHA384"
#Get-StringHash "My String to hash" "SHA512"
#http://jongurgul.com/blog/#Get-StringHash-get-filehash/
@urschrei
urschrei / parseml.py
Last active March 25, 2024 02:20
Extract attachments from EML files in the current dir, and write them to the output subdir
#!/usr/bin/env python
"""
2020 update:
- More iterators, fewer lists
- Python 3 compatible
- Processes files in parallel
(one thread per CPU, but that's not really how it works)
"""