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 / 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 / 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 / Uninstall-ModuleOldVersion
Last active October 13, 2021 09:05
Helper function to remove old module versions
function Uninstall-ModuleOldVersion {
[CmdletBinding()]
[OutputType()]
param (
[Parameter(Mandatory = $false, Position = 1)]
[string] $Module = "*"
)
#Copy & pasted from the work of Jack (@sharepointjack) - http://sharepointjack.com/2017/powershell-script-to-remove-duplicate-old-modules
#Will test all installed modules for multiple versions installed on the machine.
@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 / 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 / ConvertTo-Gif
Last active July 2, 2020 09:13
MP4 to GIF via FFMPEG
ffmpeg.exe -i "PATH.MP4" -lavfi "palettegen=stats_mode=full[palette],[0:v][palette]paletteuse=dither=sierra2_4a" "OUTPATH.gif"
ScreenToGif:
-lavfi palettegen=stats_mode=full[palette],[0:v][palette]paletteuse=new=1:diff_mode=rectangle
@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 / Test-Examples.ps1
Last active April 26, 2020 17:35
This gist is the latest version of the code that validates examples against all functions in a module. It can only validate simple examples. Any example with a pipeline in it or an example where the first code line doesn't include the name of the function that we are testing, is skipped. Green = OK test. Yellow = Skipped (advanced stuff - unable…
#Based on: https://mcpmag.com/articles/2019/04/18/pester-test-report-in-html.aspx
<#
Invoke-Pester -Path "C:\GIT\GITHUB\dbatools.Workspace\Test-Examples.ps1" -OutputFile 'C:\Temp\dbatools_pester_results.xml' -OutputFormat NUnitXml
C:\GIT\GITHUB\dbatools.Workspace\ReportUnit.exe "C:\Temp\dbatools_pester_results.xml" "C:\Temp\PesterReport.html"
Start-Process "C:\Temp\PesterReport.html"
#>
Import-Module "C:\GIT\GITHUB\dbatools.Workspace\dbatools" -Force
@Splaxi
Splaxi / Clear-LytFiles.ps1
Last active April 24, 2020 11:37
Clear lyt files from Remote Desktop Manager
Get-ChildItem -Path "C:\Users\$env:USERNAME\AppData\Local\Devolutions\RemoteDesktopManager" -Filter "*lyt" -Recurse | Remove-Item -Force -ErrorAction SilentlyContinue
#Window pane / Window tab - clear design, only navigation. Exit
Get-ChildItem -Path "C:\Users\$env:USERNAME\AppData\Local\Devolutions\RemoteDesktopManager" -Filter "*lyt" -Recurse | Remove-Item -Force -ErrorAction SilentlyContinue