Skip to content

Instantly share code, notes, and snippets.

View Splaxi's full-sized avatar

Mötz Jensen Splaxi

  • Essence Solutions P/S
  • Denmark
  • X @splaxi
View GitHub Profile
@Splaxi
Splaxi / Get-IntegrationAccounts.ps1
Created October 19, 2021 18:15
List all integration accounts, across regions, with sku details
Get-AzIntegrationAccount | Select-Object Name, Location, @{Name = "Sku"; Expression = {$_.Sku.Name}}, @{Name = "Subscription"; Expression = {$_.Id.ToString().Split('/')[2]}}
@Splaxi
Splaxi / Workbook.txt
Last active May 3, 2021 06:55
Workbook - Azure Logic App - Open directly
//If you are a guest in a customer AAD, and need to access data on their sub:
//[CustomerAADName] = contoso.com
strcat("https://portal.azure.com/[CustomerAADName]/#blade/Microsoft_Azure_EMA/LogicAppsMonitorBlade/runid/", url_encode(replace(@'/ACTIONS/.+',@'',ResourceId)))
//If your account is user account in the AAD
strcat("https://portal.azure.com/#blade/Microsoft_Azure_EMA/LogicAppsMonitorBlade/runid/", url_encode(replace(@'/ACTIONS/.+',@'',ResourceId)))
//The above example if based on failed actions, because we want to know the action in our overview, but then be able to click on the link to open the entire logic app run in a new tab, and don't have to "guess where the last error" failed, we know that from the overview. That also explains why we do a replace on /Actions/. This might NOT be needed in your example.
//The real trick is to encode the part of the "/subscriptions/...", containing the subscriptionid, resource groups name, logic app name and the runid.
@Splaxi
Splaxi / UpdateAutomationAccounts.ps1
Last active January 20, 2021 07:38
Update Azure Automation Account - AzureRm & Az modules coexists
<#
You need to read this docs page: https://docs.microsoft.com/en-us/azure/automation/automation-update-azure-modules
Download the mentioned file from the github repo: https://github.com/Microsoft/AzureAutomation-Account-Modules-Update
You need to start a new PowerShell session, without profile
from cmd you can run:
powershell.exe -nologo -noprofile
#>
$PSModuleAutoloadingPreference = "none"
@Splaxi
Splaxi / ModuleFast.ps1
Last active May 17, 2021 17:49 — forked from JustinGrote/ModuleFast.ps1
A high performance Powershell Gallery Module Installer
Add-Type -AssemblyName System.Web
Add-Type -AssemblyName System.Net.Http
$ENV:PATH="$ENV:PATH;C:\Temp\d365fo.tools\nuget"
#requires -version 5
<#
.SYNOPSIS
High Performance Powershell Module Installation
.DESCRIPTION
This is a proof of concept for using the Powershell Gallery OData API and HTTPClient to parallel install packages
@Splaxi
Splaxi / download-latest-release.ps1
Last active February 11, 2024 18:13 — forked from MarkTiedemann/download-latest-release.ps1
Download latest GitHub release via Powershell
# Download latest dotnet/codeformatter release from github
$repo = "jgm/pandoc"
$filenamePattern = "*x86_64.zip"
$pathExtract = "C:\Tools\pandoc"
$innerDirectory = $true
$preRelease = $false
if ($preRelease) {
$releasesUri = "https://api.github.com/repos/$repo/releases"
@Splaxi
Splaxi / Test-ParametersInExamples.ps1
Created April 26, 2020 19:43
Pester test that will validate all parameters that doesn't have a default value and see if there is an example with the specified parameter or not. Fails if not.
<#
Invoke-Pester -Path "C:\GIT\GITHUB\d365fo.tools.Workspace\Test-ParametersInExamples.ps1" -OutputFile 'C:\Temp\d365fo.tools_pester_results.xml' -OutputFormat NUnitXml
C:\GIT\GITHUB\dbatools.Workspace\ReportUnit.exe "C:\Temp\d365fo.tools_pester_results.xml" "C:\Temp\PesterReport-d365fo.tools.html"
Start-Process "C:\Temp\PesterReport-d365fo.tools.html"
#>
$moduleName = "d365fo.tools"
$path = "C:\GIT\GITHUB\$moduleName.Workspace\$moduleName\$moduleName"
Import-Module $path -Force
@Splaxi
Splaxi / AuthNtoAzureADwithPShellandADALHelperLib.ps1
Created February 5, 2020 12:56 — forked from darrenjrobinson/AuthNtoAzureADwithPShellandADALHelperLib.ps1
AuthN to AzureAD using PowerShell and AzureAD PSM ADAL Helper Lib
# Hack to ignore versioning of the dll file and folder structure
$folderName = (Get-ChildItem -Path "C:\Program Files\WindowsPowerShell\Modules\AzureAD\2.0.*\Microsoft.IdentityModel.Clients.ActiveDirectory.dll").Directory.Name | Sort-Object -Descending | Select-Object -First 1
# ADAL Helper Lib
Add-Type -Path "c:\Program Files\WindowsPowerShell\Modules\AzureAD\$folderName\Microsoft.IdentityModel.Clients.ActiveDirectory.dll"
# Azure tenant
$tenant = ""
# Application ID for Powershell client
$client_Id = "1950a258-227b-4e31-a9cf-717495945fc2"
# Login URI
@Splaxi
Splaxi / Convert-HashTableToString.ps1
Created January 31, 2020 09:21
Convert Hashtable to string to share hashtable with others
function Convert-HashTableToString {
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidDefaultValueSwitchParameter", "")]
[CmdletBinding()]
[OutputType([System.String])]
param (
[HashTable] $InputObject,
[string] $KeyPrefix = "",
[string] $ValuePrefix = " = ",
@Splaxi
Splaxi / Register-NuGetProviderV2.ps1
Created December 18, 2019 07:53
Register NuGet v2 provider
Register-PackageSource nugetV2 https://www.nuget.org/api/v2 -ProviderName NuGet -Trusted
@Splaxi
Splaxi / Get-PrivateMethods.ps1
Last active November 30, 2019 17:13
.NET Reflection
[Reflection.Assembly]$ass = [Reflection.Assembly]::LoadFile("C:\Temp\File.dll")
$specificType = $ass.GetType("Namespace.Type")
$specificType.GetMethods([System.Reflection.BindingFlags]::NonPublic -bor [System.Reflection.BindingFlags]::Instance)
$instanceTypeObj = [System.Activator]::CreateInstance("Namespace.Type")
$nameOfMethod = $specificType.GetMethod("NameOfMethod", [System.Reflection.BindingFlags]::NonPublic -bor [System.Reflection.BindingFlags]::Instance)